RFR: 8367972: ZGC: Reduce ZBarrierSet includes
Francesco Andreuzzi
fandreuzzi at openjdk.org
Fri Sep 19 11:50:57 UTC 2025
On Fri, 19 Sep 2025 09:49:03 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:
> [JDK-8365053](https://bugs.openjdk.org/browse/JDK-8365053) made a fact which is already well known to ZGC developers clear. We pull in large parts of the ZGC implementation through the access API, via `zbarrierset.inline.hpp`.
>
> ZGC developers are well aware as touching most `.hpp` or `inline.hpp` files in `gc/z` requires rebuilding most of hotspot in incremental builds.
>
> I propose we create a boundary between the barrier set and the implementation. The main reason being making incremental builds less painful.
>
> I experimented with this last year, at the time I saw no real difference in full build times, nor any performance regressions from not inlining the barrier implementation into the access API.
>
> Will reevaluate the performance implications.
>
> I ran the `bin/update_pch.sh` script, but with the default `MIN_MS` I saw the same list both before and after this change:
> ```c++
> #include "gc/g1/g1BarrierSet.inline.hpp"
> #include "gc/shenandoah/shenandoahHeap.inline.hpp"
> #include "memory/iterator.inline.hpp"
> #include "oops/access.hpp"
> #include "oops/access.inline.hpp"
> #include "oops/oop.inline.hpp"
> #include "utilities/globalDefinitions.hpp"
>
> However when running with `MIN_MS` reduced by an order of magnitude `#include "gc/z/zBarrier.inline.hpp"` was included without this patch, and was excluded after with this patch.
>
> Also cross-compiled ppc64le, s390x and riscv64 (fast debug). Could not find any missing includes, have not built all configurations.
>
> For some reason windows slow debug failed to build because `test/hotspot/gtest/runtime/test_os_windows.cpp` was missing `os_windows.hpp`, did not investigate further, but included `runtime/os.inline.hpp` in the test as it includes all OS and OS CPU specific declarations and inline definitions.
>
> * Testing
> * Tier 1 + ZGC tier 1-5 on Oracle supported platforms
Hi @xmas92, some more data about this change.
### Before
./ClangBuildAnalyzer/build/ClangBuildAnalyzer --analyze cba_out_20250919-1055 | grep /z/ -A 3
126184 ms: /jdk/src/hotspot/share/gc/z/zGeneration.inline.hpp (included 646 times, avg 195 ms), included via:
81x: oop.inline.hpp iterator.inline.hpp access.inline.hpp barrierSetConfig.inline.hpp zBarrierSet.inline.hpp zBarrier.inline.hpp
...
121644 ms: /jdk/src/hotspot/share/gc/z/zBarrier.inline.hpp (included 646 times, avg 188 ms), included via:
81x: oop.inline.hpp iterator.inline.hpp access.inline.hpp barrierSetConfig.inline.hpp zBarrierSet.inline.hpp
...
109125 ms: /jdk/src/hotspot/share/gc/z/zHeap.inline.hpp (included 646 times, avg 168 ms), included via:
81x: oop.inline.hpp iterator.inline.hpp access.inline.hpp barrierSetConfig.inline.hpp zBarrierSet.inline.hpp zBarrier.inline.hpp zGeneration.inline.hpp
...
--
61224 ms: /jdk/src/hotspot/share/gc/z/zForwardingTable.inline.hpp (included 646 times, avg 94 ms), included via:
81x: oop.inline.hpp iterator.inline.hpp access.inline.hpp barrierSetConfig.inline.hpp zBarrierSet.inline.hpp zBarrier.inline.hpp zGeneration.inline.hpp zHeap.inline.hpp
...
--
58889 ms: /jdk/src/hotspot/share/gc/z/zForwarding.inline.hpp (included 646 times, avg 91 ms), included via:
81x: oop.inline.hpp iterator.inline.hpp access.inline.hpp barrierSetConfig.inline.hpp zBarrierSet.inline.hpp zBarrier.inline.hpp zGeneration.inline.hpp zHeap.inline.hpp zForwardingTable.inline.hpp
...
### After
./ClangBuildAnalyzer/build/ClangBuildAnalyzer --analyze after | grep /z/ -A 3
31714 ms: /jdk/src/hotspot/share/gc/z/zHeap.inline.hpp (included 40 times, avg 792 ms), included via:
13x: zBarrier.inline.hpp zGeneration.inline.hpp
...
--
31012 ms: /jdk/src/hotspot/share/gc/z/zForwarding.inline.hpp (included 40 times, avg 775 ms), included via:
13x: zBarrier.inline.hpp zGeneration.inline.hpp zHeap.inline.hpp zForwardingTable.inline.hpp
...
--
27089 ms: /jdk/src/hotspot/share/gc/z/zForwardingTable.inline.hpp (included 40 times, avg 677 ms), included via:
13x: zBarrier.inline.hpp zGeneration.inline.hpp zHeap.inline.hpp
...
27058 ms: /jdk/src/hotspot/share/gc/z/zGeneration.inline.hpp (included 40 times, avg 676 ms), included via:
13x: zBarrier.inline.hpp
...
``
-------------
PR Comment: https://git.openjdk.org/jdk/pull/27386#issuecomment-3311893573
More information about the hotspot-dev
mailing list