RFR: 8345801: C2: Clean up include statements to speed up compilation when touching type.hpp
Christian Hagedorn
chagedorn at openjdk.org
Tue Dec 10 09:39:48 UTC 2024
I've noticed that after touching `type.hpp` in Valhalla, it requires more than 7 minutes to build hotspot again on my machine. I would have suspected that we mostly recompile C2/opto source files. But that is far from the truth: A lot of unrelated source files must be recompiled, including, for example, C1, JFR, or runtime files.
In mainline, the impact is not that severe. But it still requires around 1 minute to build hotspot again on my machine after touching `type.hpp`. I've had a look at the include chains and removed quite a lot of unused includes. For the active includes, the most impact had including `output.hpp` inside `c2compiler.hpp`. This set up the following dependency chain:
... more C1 files
#include "c1/c1_Compilation.hpp"
#include "compiler/compilerDefinitions.inline.hpp"
#include "opto/c2compiler.hpp"
#include "opto/output.hpp" <------------ Problematic include
#include "opto/c2_CodeStubs.hpp"
#include "opto/compile.hpp"
... more opto files and eventually type.hpp
This means that a lot of C1 files also need to be re-compiled as well as some more source file that include `compiler/compilerDefinitions.inline.hpp`. I cut this dependency chain by removing the include of `opto/output.hpp` in `opto/c2compiler.hpp` and moved the constant `initial_const_capacity` from `output.hpp` to `c2Compiler.hpp` which seemed to be the only reason why we have the include in place. After this change, I was required to add some missing includes that were included transitively before.
The final mainline patch could also be applied to the current Valhalla repository (with some small tweaks). The results were quite promising. I could bring the compilation time on my machine significantly down in mainline and especially in Valhalla after touching `type.hpp`:
- Mainline: ~1min -> ~40s (1.5 times faster)
- Valhalla: ~7min -> ~40s (10.5 times faster)
I've only focused on `type.hpp` here but I guess other includes in the JIT compiler area or other parts of hotspot could also be revisited to possibly speed up the compilation after touching some header files.
Testing:
- Oracle CI
- GHA
Maybe some
Thanks,
Christian
-------------
Commit messages:
- C2: Clean up include statements to speed up compilation when touching type.hpp
Changes: https://git.openjdk.org/jdk/pull/22658/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=22658&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8345801
Stats: 86 lines in 31 files changed: 15 ins; 69 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/22658.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/22658/head:pull/22658
PR: https://git.openjdk.org/jdk/pull/22658
More information about the graal-dev
mailing list