Skip to content

8385596: Shenandoah: Introduce per-partition allocators with FreeSet API boundary#31327

Draft
pengxiaolong wants to merge 17 commits into
openjdk:masterfrom
pengxiaolong:shenandoah-per-partition-allocator
Draft

8385596: Shenandoah: Introduce per-partition allocators with FreeSet API boundary#31327
pengxiaolong wants to merge 17 commits into
openjdk:masterfrom
pengxiaolong:shenandoah-per-partition-allocator

Conversation

@pengxiaolong
Copy link
Copy Markdown

@pengxiaolong pengxiaolong commented May 29, 2026

Follow-up to JDK-8385592 (allocator interface).

This change introduces per-partition allocator instances (Mutator, Collector, OldCollector) templated on partition ID, and establishes a clean API boundary between allocators and ShenandoahFreeSet.

Key changes:

  • ShenandoahPartitionAllocator handles allocation within a single partition, with partition-specific logic resolved at compile time via if constexpr
  • ShenandoahFreeSet exposes public APIs for allocators: find_region_for_alloc, steal_from_mutator, increase_partition_used, mark_region_used, retire_region, notify_allocation
  • Allocators no longer access FreeSet internals — no friend declarations
  • Heap lock acquisition moved from ShenandoahHeap into the allocator (ShenandoahSerialAllocator), making the locking strategy an allocator responsibility
  • Old-gen capacity check moved into the OldCollector partition allocator
  • Retained region optimization: each partition retains the last region with remaining capacity to avoid rescanning the free set on consecutive allocations

This establishes the foundation for the CAS-based allocator, which will use the same FreeSet APIs(and some new APIs) but manage its own locking (CAS fast path, locked slow path).

No behavioral change — the same region-selection logic runs under the heap lock as before.



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-8385596: Shenandoah: Introduce per-partition allocators with FreeSet API boundary (Sub-task - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 31327

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

Using diff file

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

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented May 29, 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 29, 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 29, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented May 29, 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 29, 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.

@openjdk
Copy link
Copy Markdown

openjdk Bot commented May 30, 2026

⚠️ @pengxiaolong This pull request contains merges that bring in commits not present in the target repository. Since this is not a "merge style" pull request, these changes will be squashed when this pull request in integrated. If this is your intention, then please ignore this message. If you want to preserve the commit structure, you must change the title of this pull request to Merge <project>:<branch> where <project> is the name of another project in the OpenJDK organization (for example Merge jdk:master).

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 shenandoah shenandoah-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

1 participant