-
Notifications
You must be signed in to change notification settings - Fork 21
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
Improve build times #1573
Comments
I was exploring the flame charts a bit. I noticed a number of standard library includes appeared to be kind of heavy:
Unfortunately those are pretty standard, and pretty widespread. Still, it may be possible to move some dependencies out of header files and into source files, where they will have less of a transitive effect. Of note, the I noticed a number of NAS2D headers appeared to be a bit heavy, though sometimes depending on what's already been included. For instance, if Heavy includes:
Medium includes:
Notable includes of OPHD headers:
One of the most notable includes was the widespread use of |
Did a little more exploring with Clang's To get a list of includes, and the duration needed to process them: jq -r '[.traceEvents[] | select(.name=="Source") | {dur, path: .args.detail}] | sort_by(.dur) | .[] | join(" ")' .build/Debug_Linux_appOPHD/Intermediate/main.json The paths to standard library includes are not canonical, such as: realpath /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/memory
Unfortunately The paths are consistent with the path structure though, so a single echo "/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/memory" | sed -r 's+bin/\.\./lib/gcc/x86_64-linux-gnu/12/\.\./\.\./\.\./\.\./++g'
Combining that into one pipe: jq -r '[.traceEvents[] | select(.name=="Source") | {dur, path: .args.detail}] | sort_by(.dur) | .[] | join(" ")' .build/Debug_Linux_appOPHD/Intermediate/main.json | sed -r 's+bin/\.\./lib/gcc/x86_64-linux-gnu/12/\.\./\.\./\.\./\.\./++g' Potentially useful, is getting a list of all the standard library includes used directly by the project: grep -rh "#include <[^/]*>" appOPHD/ | sed -e 's/^[ \t]*//' | sort | uniq Note that we identify standard library includes here by the absence of a This output differs from the The For non-standard library includes, there is usually a "projectName/" prefix to the include. Hence non-standard library includes can be found with: grep -rh "#include <.*/.*>" appOPHD/ | sed -e 's/^[ \t]*//' | sort | uniq |
Ideas taken from:
Commands from the above linked issues were used with GCC, Clang, and MSBuild to get build time reports.
Related idea, since the project is being split into sub projects, it may be possible to cache build outputs per sub project, which may help improve incremental build performance.
GCC:
make CXXFLAGS_EXTRA="-ftime-report"
GCC showed the vast majority of the time was spent parsing, with template instantiation a distant 2nd.
Clang results are a bit harder to read and draw conclusions from. Seems most of the time was spent on various passes and analysis, and also a good chunk on code generation.
It's also possible to include the
-ftime-trace
flag to get.json
output alongside the object files:The output can be viewed using Chrome:
chrome://tracing/
Drag and drop a trace file into Chrome, such as:
.build/Debug_Linux_appOPHD/Intermediate/main.json
These flame charts are very useful for determining which header files are slow to
#include
and parse. Sometimes the results are surprising.There was an outdated note about getting build timings from MSVC using:
Documentation:
https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-command-line-reference?view=vs-2022
Of interest is the documentation for the
-consoleLoggerParameters
flag, which is related to the-fileLoggerParameters
(-flp
) flag.It seems the
Verbosity=diagnostic
flag no longer displays timing information, though it does give a lot of other detailed information. Some timing information can be found usingPerformanceSummary
:For MSVC there also appear to be some undocumented compiler (
/Bt
,/Bt+
) and linker (/time
,/time+
) flags:https://devblogs.microsoft.com/cppblog/vc-tip-get-detailed-build-throughput-diagnostics-using-msbuild-compiler-and-linker/
Similarly there is also an undocumented flag
/d2cgsummary
:https://aras-p.info/blog/2017/10/23/Best-unknown-MSVC-flag-d2cgsummary/
Of these options, the
-ftime-trace
option for Clang, and the Chrome flame chart display atchrome://tracing/
appear to be the most promising tool for investigating and improving build times.The text was updated successfully, but these errors were encountered: