-
Notifications
You must be signed in to change notification settings - Fork 490
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
Very slow build because of system.hh header file bottleneck #2339
Comments
I'd like to believe that precompiled headers should mitigate some the compile performance issues. Could it be that precompiled headers aren't working anymore / for you, @riastradh? |
It looks like, in ledger, precompiled headers are enabled only for debug builds: Line 150 in c679e3c
What I've been running locally in my ledger development tree, and in pkgsrc, has not been debug builds. I tried a debug build, and it is spewing warning messages about pch files:
The debug build appears to be just as slow as the release build. Does this precompiled header mechanism rely on something kooky like disabling ASLR in the system? (I don't think I've ever seen precompiled headers work, over decades of encountering them in various build systems, compilers, and operating systems. I still have -no-cpp-precomp wired into my fingers from two decades ago when it was needed to make just about any software build in an Apple environment...) |
Unfortunately I cannot answer your question about disabling ASLR, my expertise in the area is too little and the pch mechanism was added before I started contributing to ledger. |
It would likely be much faster if each .cc file included only the header files it uses. For example, .cc files that don't handle pathnames or do file I/O probably don't need to include anything under boost/filesystem/. Inside ledger, if a class A is declared in A.hh, and a class B is declared in B.hh with members or parameters that are pointers or references to A, you can also use forward declarations to reduce interdependencies between header files, which can help speed things up too:
|
Could the ledger API documentation be helpful here in order to find which classes depend on/use which other classes? |
Just about every .cc file includes system.hh, and system.hh includes 84 header files including STL and boost.
Just the boost header files that are directly included alone, not counting STL header files or transitive inclusions, bring in half a megabyte of C++ code.
When I pass one of the smallest files in the build, mask.cc, through
c++ -E
to find the C preprocessor expansion, it turns out at 7.5 MB of C++ source code -- with no comments.This makes builds very slow, because the compiler has to slog through megabytes of heavy-weight C++ declarations and templates that mostly aren't used by most of the .cc files. That, in turn, makes iterating development very slow -- takes minutes on my laptop to build ledger, which isn't a very large piece of software, even when I parallelize it to the maximum degree of my CPU (4-core/8-thread Kaby Lake 1.9 GHz).
It would be nice if each .cc file included only the header files it needs to speed up the build.
The text was updated successfully, but these errors were encountered: