Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: re-order headers and forward declarations to improve compile time #5693

Merged
merged 15 commits into from
Nov 17, 2023

Conversation

knst
Copy link
Collaborator

@knst knst commented Nov 13, 2023

Issue being fixed or feature implemented

Some headers include other heavy headers, such as logging.h, tinyformat.h, iostream. These headers are heavy and increase compilation time on scale of whole project drastically because can be used in many other headers.

What was done?

Moved many heavy includes from headers to cpp files to optimize compilation time.
In some places added forward declarations if it is reasonable.

As side effect removed 2 circular dependencies:

"llmq/debug -> llmq/dkgsessionhandler -> llmq/debug"
"llmq/debug -> llmq/dkgsessionhandler -> llmq/dkgsession -> llmq/debug"

How Has This Been Tested?

Run build 2 times before refactoring and after refactoring: make clean && sleep 10s; time make -j18

Before refactoring:

real    5m37,826s
user    77m12,075s
sys     6m20,547s

real    5m32,626s
user    76m51,143s
sys     6m24,511s

After refactoring:

real    5m18,509s
user    73m32,133s
sys     6m21,590s

real    5m14,466s
user    73m20,942s
sys     6m17,868s

~5% of improvement for compilation time. That's not huge, but that's worth to get merged

There're several more refactorings TODO but better to do them later by backports:

Breaking Changes

N/A

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone

@knst knst added this to the 20.1 milestone Nov 13, 2023
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make -j7 clean && ./autogen.sh && ./configure --enable-crash-hooks --enable-werror --enable-suppress-external-warnings --prefix=pwd/depends/aarch64-apple-darwin22.6.0 --disable-ccache && time make -j7

develop:
make -j7  1011.18s user 77.76s system 636% cpu 2:51.15 total
make -j7  1014.88s user 78.29s system 634% cpu 2:52.28 total

5693:
make -j7  1011.06s user 80.08s system 620% cpu 2:55.93 total
make -j7  1004.36s user 78.48s system 636% cpu 2:50.02 total

i.e. no improvement in compilation time for me but I like these changes anyway so

utACK

Copy link
Collaborator

@ogabrielides ogabrielides left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

knst added 15 commits November 16, 2023 21:28
Good job! The circular dependency "llmq/debug -> llmq/dkgsessionhandler -> llmq/debug" is no longer present.
Please remove it from EXPECTED_CIRCULAR_DEPENDENCIES in test/lint/lint-circular-dependencies.sh
to make sure this circular dependency is not accidentally reintroduced.

Good job! The circular dependency "llmq/debug -> llmq/dkgsessionhandler -> llmq/dkgsession -> llmq/debug" is no longer present.
Please remove it from EXPECTED_CIRCULAR_DEPENDENCIES in test/lint/lint-circular-dependencies.sh
to make sure this circular dependency is not accidentally reintroduced.
@UdjinM6 UdjinM6 force-pushed the build-optimize-headers branch from 6a39a73 to 8518694 Compare November 16, 2023 18:28
@UdjinM6
Copy link

UdjinM6 commented Nov 16, 2023

rebased from GH GUI to fix Merge Fast-Forward Only check

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK for squash merge

@PastaPastaPasta PastaPastaPasta merged commit ba97f49 into dashpay:develop Nov 17, 2023
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants