RFR: 8367993: G1: Speed up ConcurrentMark initialization [v5]

Stefan Johansson sjohanss at openjdk.org
Thu Jan 22 14:52:13 UTC 2026


On Thu, 22 Jan 2026 12:36:42 GMT, Leo Korinth <lkorinth at openjdk.org> wrote:

>> This change moves almost all of the ConcurrentMark initialisation from its constructor to the method `G1ConcurrentMark::fully_initialize()`.  Thus, creation time of the VM can be slightly improved by postponing creation of ConcurrentMark. Most time is saved postponing creation of statistics buffers and threads.
>> 
>> It is not obvious that this is the best solution. I have earlier experimented with lazily allocating statistics buffers _only_. One could also initialise a little bit more eagerly (for example the concurrent mark thread) and maybe get a slightly cleaner change. However IMO it seems better to not have ConcurrentMark "half initiated" with a created mark thread, but un-initialised worker threads.
>> 
>> This change is depending on the integration of https://bugs.openjdk.org/browse/JDK-8373253.
>> 
>> I will be out for vacation, and will be back after new year (and will not answer questions during that time), but I thought I get the pull request out now so that you can have a look.
>
> Leo Korinth has updated the pull request incrementally with six additional commits since the last revision:
> 
>  - Merge branch '_8373253' into _8367993
>  - rename of method
>  - Proposal by Stefan J
>  - wip
>  - Revert "8373253: Re-work InjectGCWorkerCreationFailure for future changes"
>    
>    This reverts commit d45ea8817ab2303b2decd8cbb2cd1bf5280aa181.
>  - Revert "Fixup after comment from Ivan."
>    
>    This reverts commit 2aa8aa4b68027b62a8d4be1b86720fadfa48dda5.

Thanks for addressing my comments, I think this looks good now. 

Only one comment about an additional (and optional) change, if we can do the CM initialization after the young collection and only when we start the concurrent mark cycle. But there might be things preventing this.

src/hotspot/share/gc/g1/g1CollectedHeap.cpp line 2745:

> 2743:   // without its logging output interfering with the logging output
> 2744:   // that came from the pause.
> 2745:   if (should_start_concurrent_mark_operation) {

Did you try doing the initialization here? Would be kind of nice to only initialize CM if ever needed.

-------------

Marked as reviewed by sjohanss (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/28723#pullrequestreview-3692812069
PR Review Comment: https://git.openjdk.org/jdk/pull/28723#discussion_r2717200084


More information about the hotspot-gc-dev mailing list