Skip to content

8385592: Shenandoah: Introduce ShenandoahAllocator interface to encapsulate memory allocation#31314

Open
pengxiaolong wants to merge 7 commits into
openjdk:masterfrom
pengxiaolong:shenandoah-allocator-interface
Open

8385592: Shenandoah: Introduce ShenandoahAllocator interface to encapsulate memory allocation#31314
pengxiaolong wants to merge 7 commits into
openjdk:masterfrom
pengxiaolong:shenandoah-allocator-interface

Conversation

@pengxiaolong
Copy link
Copy Markdown

@pengxiaolong pengxiaolong commented May 28, 2026

The memory allocation path in ShenandoahGC is currently embedded within ShenandoahFreeSet, mixing region-selection strategy with partition management and accounting. This coupling makes it difficult to experiment with alternative allocation strategies (e.g., CAS-based concurrent allocation).

This change introduces a ShenandoahAllocator interface and a concrete ShenandoahSerialAllocator implementation that extracts the allocation logic out of ShenandoahFreeSet. The serial allocator performs all allocations under the heap lock, preserving existing behavior:

  • Mutator allocations from the Mutator partition with left/right bias alternation
  • Collector allocations from Collector/OldCollector partitions with affiliation preference
  • Overflow stealing of empty regions from Mutator for collector use
  • Humongous allocations delegated to ShenandoahFreeSet::allocate_contiguous()

Partition accounting (used/capacity tracking, region retirement, affiliated region totals) remains in ShenandoahFreeSet, invoked by the allocator via notify_allocation().

ShenandoahHeap now owns the allocator instance and calls it directly, replacing the previous ShenandoahFreeSet::allocate() call site.

This is a pure refactoring — no behavioral change.

Test:

  • MacOS aarch64 fastdebug, hotspot_gc_shenandoah
  • Internal benchmark CI


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8385592: Shenandoah: Introduce ShenandoahAllocator interface to encapsulate memory allocation (Sub-task - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/31314/head:pull/31314
$ git checkout pull/31314

Update a local copy of the PR:
$ git checkout pull/31314
$ git pull https://git.openjdk.org/jdk.git pull/31314/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 31314

View PR using the GUI difftool:
$ git pr show -t 31314

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/31314.diff

Using Webrev

Link to Webrev Comment

…r-interface

# Conflicts:
#	src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp
#	src/hotspot/share/gc/shenandoah/shenandoahFreeSet.hpp
@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented May 28, 2026

👋 Welcome back xpeng! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link
Copy Markdown

openjdk Bot commented May 28, 2026

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk Bot added hotspot-gc hotspot-gc-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org labels May 28, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented May 28, 2026

@pengxiaolong The following labels will be automatically applied to this pull request:

  • hotspot-gc
  • shenandoah

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk
Copy link
Copy Markdown

openjdk Bot commented May 28, 2026

The total number of required reviews for this PR has been set to 2 based on the presence of this label: hotspot-gc. This can be overridden with the /reviewers command.

@pengxiaolong pengxiaolong changed the title Shenandoah: Encapsulate memory allocation path into SheandoahAllocator interface 8385592: Shenandoah: Encapsulate memory allocation path into SheandoahAllocator interface May 28, 2026
@pengxiaolong pengxiaolong changed the title 8385592: Shenandoah: Encapsulate memory allocation path into SheandoahAllocator interface 8385592: Shenandoah: Introduce ShenandoahAllocator interface to encapsulate heap allocation May 28, 2026
@pengxiaolong pengxiaolong changed the title 8385592: Shenandoah: Introduce ShenandoahAllocator interface to encapsulate heap allocation 8385592: Shenandoah: Introduce ShenandoahAllocator interface to encapsulate memory allocation May 28, 2026
@pengxiaolong pengxiaolong marked this pull request as ready for review May 28, 2026 20:26
@openjdk openjdk Bot added the rfr Pull request is ready for review label May 28, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge Bot commented May 28, 2026

Webrevs

Copy link
Copy Markdown
Contributor

@kdnilsen kdnilsen left a comment

Choose a reason for hiding this comment

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

Thanks for this refactoring. It establishes a good foundation for further integrations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-gc hotspot-gc-dev@openjdk.org rfr Pull request is ready for review shenandoah shenandoah-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

2 participants