RFR: 8345801: C2: Clean up include statements to speed up compilation when touching type.hpp
Dean Long
dlong at openjdk.org
Wed Dec 11 02:13:37 UTC 2024
On Tue, 10 Dec 2024 09:31:27 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:
> 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
>
> Thanks,
> Christian
Looks good, as long as you tested w/ and w/o precompiled headers.
src/hotspot/share/opto/node.hpp line 2003:
> 2001: }
> 2002:
> 2003: inline Node_Notes* Compile::node_notes_at(int idx) {
It seems weird to have these inlined Compile methods in node.hpp. Could we clean this up separately, maybe by moving them to compile.inline.hpp?
-------------
Marked as reviewed by dlong (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/22658#pullrequestreview-2494128348
PR Review Comment: https://git.openjdk.org/jdk/pull/22658#discussion_r1879215004
More information about the hotspot-dev
mailing list