compile-size
BuilderThe compile-size
trybot measures and prevents unexpected growth in the size of the C++ compiler input size, which closely correlates with time spent in the build.
This builder does the following:
chrome
on Linuxcompile-size
builder's overview or infra page look for the summary and the link to the compile_size_deltas.txt
report. If you want to check TU sizes locally to iterate faster, do the following:
# Set up a new build directory with the builder's GN args tools/mb/mb gen -m tryserver.chromium.linux -b compile-size out/compile_size # Build the `chrome` target autoninja -C out/compile_size chrome # Collect the size info siso query commands -C out/compile_size chrome > /tmp/commands.txt siso query deps -C out/compile_size > /tmp/deps.txt tools/clang/scripts/compiler_inputs_size.py out/compile_size \ /tmp/commands.txt /tmp/deps.txt > /tmp/report.txt
The report will contain lines with compile sizes in bytes per TU, like
apps/app_lifetime_monitor.cc 9,034,754 apps/app_lifetime_monitor_factory.cc 5,863,660 apps/app_restore_service.cc 9,198,130
As you make changes, you can re-build, collect size info, and generate reports to see how the per-TU numbers change. Two reports can be diffed with compiler_inputs_size_diff.py.
tools/clang/scripts/compiler_inputs_size_diff.py /tmp/report-old.txt \ /tmp/report-new.txt > /tmp/diff-report.txt
Once done iterating on a fix locally (or if you skipped local iterations), you can upload a new patchset or CL and trigger the compile-size
builder to get a new result and report.
A common source of compiler input size growth is adding a header to another widely included header. This can result in the added header getting compiled an additional thousands or tens of thousands of times.
Chromium style prefers forward declarations over includes when a full definition isn't required. For advice on when to use forward declarations and how to minimize code in headers see these tips.
Example CLs replacing header inclusion with forward declarations resulting in large compiler input size decreases:
For help, post to build@chromium.org. They're expert build system developers. You may also ask #cxx or #halp on Chromium slack.
Not all checks are perfect and sometimes you want to bypass the builder (for example, if you did your best and are unable to reduce compiler input size any further).
Adding a Compile-Size: $ANY_TEXT_HERE
footer to your CL description (above or below Bug:
) will bypass the builder assertions.
Examples:
Compile-Size: Size increase is unavoidable.
Compile-Size: Increase is temporary.
Compile-Size: See commit description.
<-- use this if longer than one line.Compile-Size:
and other footers.The analysis is done with the following scripts:
The GN args are in the builder's gn-args.json file.