RFR: 8370850: Shenandoah: Simplify collector allocation to save unnecessary region iteration

Xiaolong Peng xpeng at openjdk.org
Wed Oct 29 23:29:37 UTC 2025


To allocate an object in Collector/OldCollector partition, current implementation may traverse the regions in the partition twice:
1. fast path: traverse regions between left most and right most in the partition,  and try to allocate in an affiliated region in the partition;  
2. if fails in fast path, traverse regions between left most empty and right most empty in the partition, and try try to allocate in a FREE region.

#2 can be saved if we also remember the first FREE region seem in #1.

The PR makes the code much cleaner, and and more efficient(although the performance impact may not be measurable, I have run some dacapo benchmarks and didn't see meaningful difference) 


Test:
- [x] hotspot_gc_shenandoah

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

Commit messages:
 - Merge branch 'openjdk:master' into collector-allocation
 - Touch up
 - Remove test 'req.is_old()' when steal an empty region from the mutator view
 - Update comment
 - Fix wrong condition when steal an empty region from the mutator view
 - Fix potential failure in young evac
 - fix and touch up
 - Fix wrong condition to find first empty region
 - Simplify ShenandoahFreeSet::allocate_for_collector for better allocation performance

Changes: https://git.openjdk.org/jdk/pull/28036/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=28036&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8370850
  Stats: 72 lines in 2 files changed: 16 ins; 46 del; 10 mod
  Patch: https://git.openjdk.org/jdk/pull/28036.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/28036/head:pull/28036

PR: https://git.openjdk.org/jdk/pull/28036


More information about the hotspot-gc-dev mailing list