Skip to content

Support generational ZGC and generational Shenandoah#26676

Closed
jjudd wants to merge 1 commit intobazelbuild:masterfrom
lucidsoftware:jjudd-gen-zgc-support
Closed

Support generational ZGC and generational Shenandoah#26676
jjudd wants to merge 1 commit intobazelbuild:masterfrom
lucidsoftware:jjudd-gen-zgc-support

Conversation

@jjudd
Copy link
Copy Markdown
Contributor

@jjudd jjudd commented Aug 1, 2025

Bazel currently does not start when you launch the server JVM with generational ZGC using -XX:+UseZGC and -XX:+ZGenerational. Or if you're on JDK 24+ the same problem is encountered with just -XX:+UseZGC.

The same problem is encountered with -XX:+UseShenandoahGC and -XX:ShenandoahGCMode=generational.

Non-generational ZGC is removed as of JDK 24. Generational Shenandoah is being promoted from experimental to production in JDK 25.

This fix is modeled after #12644

Bazel currently does not start when you launch the server JVM with
generational ZGC using -XX:+UseZGC and -XX:+ZGenerational. Or if you're
on JDK 24+ the same problem is encountered with just -XX:+UseZGC.

The same problem is encountered with -XX:+UseShenandoahGC and
-XX:ShenandoahGCMode=generational.

Non-generational ZGC is removed as of JDK 24. Generational Shenandoah is
being promoted from experimental to production in JDK 25.

This fix is modeled after bazelbuild#12644
@github-actions github-actions Bot added team-Performance Issues for Performance teams awaiting-review PR is awaiting review from an assigned reviewer labels Aug 1, 2025
@jjudd
Copy link
Copy Markdown
Contributor Author

jjudd commented Aug 1, 2025

FWIW, I tested this by building Bazel with this change, then used it to build some non-trivial Scala targets in our main monorepo on JDK 24 using generational ZGC and then again with generational Shenandoah.

Bazel failed to start with either GC before this change. After this change both built successfully.

Copy link
Copy Markdown
Collaborator

@fmeum fmeum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, did you see better overall performance with one of these GCs?

@jjudd
Copy link
Copy Markdown
Contributor Author

jjudd commented Aug 1, 2025

Good question and one I intend to answer, but haven't yet. I went to play around with Generational ZGC to see if it had any noticeable impact on builds and ran into this issue.

I know it's not Bazel, but our production application has been using generational ZGC for a while now. It does a great job of decreasing tail latency and overall we're quite happy with it. That said, we did run into some native memory challenges at the start. In particular we noticed https://bugs.openjdk.org/browse/JDK-8339161 which is fixed in JDK 24.

We were able to mitigate some of the native memory pressure using -XX:TrimNativeHeapInterval. Without that flag we found temporary malloc spikes resulted in long lasting increases to memory footprint . I've been meaning to try that flag with Bazel as well, but it hasn't made it to the top of the todo list yet.

@fmeum
Copy link
Copy Markdown
Collaborator

fmeum commented Aug 1, 2025

@bazel-io fork 8.4.0

@meisterT meisterT added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Aug 1, 2025
@copybara-service copybara-service Bot closed this in 3a1fe64 Aug 1, 2025
@github-actions github-actions Bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Aug 1, 2025
bazel-io pushed a commit to bazel-io/bazel that referenced this pull request Aug 1, 2025
Bazel currently does not start when you launch the server JVM with generational ZGC using `-XX:+UseZGC` and `-XX:+ZGenerational`. Or if you're on JDK 24+ the same problem is encountered with just `-XX:+UseZGC`.

The same problem is encountered with `-XX:+UseShenandoahGC` and `-XX:ShenandoahGCMode=generational`.

Non-generational ZGC is removed as of JDK 24. Generational Shenandoah is being promoted from experimental to production in JDK 25.

This fix is modeled after bazelbuild#12644

Closes bazelbuild#26676.

PiperOrigin-RevId: 789746919
Change-Id: Ia070fa9b39cef07cc9987544c014d589b2504dce
github-merge-queue Bot pushed a commit that referenced this pull request Aug 4, 2025
Bazel currently does not start when you launch the server JVM with
generational ZGC using `-XX:+UseZGC` and `-XX:+ZGenerational`. Or if
you're on JDK 24+ the same problem is encountered with just
`-XX:+UseZGC`.

The same problem is encountered with `-XX:+UseShenandoahGC` and
`-XX:ShenandoahGCMode=generational`.

Non-generational ZGC is removed as of JDK 24. Generational Shenandoah is
being promoted from experimental to production in JDK 25.

This fix is modeled after #12644

Closes #26676.

PiperOrigin-RevId: 789746919
Change-Id: Ia070fa9b39cef07cc9987544c014d589b2504dce

Commit
3a1fe64

Co-authored-by: James Judd <[email protected]>
CyrusNajmabadi pushed a commit to CyrusNajmabadi/bazel that referenced this pull request Feb 11, 2026
JDK 21+ introduces generational ZGC ("ZGC Old Generation") and
generational Shenandoah ("Shenandoah Old Gen"). Bazel's
isTenuredSpace() only knew the older pool names ("ZHeap",
"Shenandoah"), causing MemoryPressureModule to crash on startup
when using these collectors.

This is a backport of the upstream fix:
- Issue: bazelbuild#26676
- PR: bazelbuild#26684
- Commit: bazelbuild@3a1fe64

Co-authored-by: Cursor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-Performance Issues for Performance teams

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants