RFR: 8345801: C2: Clean up include statements to speed up compilation when touching type.hpp
Christian Hagedorn
chagedorn at openjdk.org
Wed Dec 11 13:21:37 UTC 2024
On Wed, 11 Dec 2024 13:08:27 GMT, Julian Waters <jwaters 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
>
> It takes just 7 minutes to compile and link HotSpot for you? If only I had that kind of luxury...
Thanks @TheShermanTanker for your review! The measured numbers are only when starting a hotspot build again after touching `type.hpp`. It takes slightly longer for a full `make hotspot` in Valhalla.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/22658#issuecomment-2535972320
More information about the graal-dev
mailing list