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

Xiaolong Peng xpeng at openjdk.org
Fri Oct 31 15:31:23 UTC 2025


On Fri, 31 Oct 2025 01:10:23 GMT, William Kemper <wkemper at openjdk.org> wrote:

>> 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 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
>
> src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp line 901:
> 
>> 899:   }
>> 900: 
>> 901:   bool allow_new_region = can_allocate_in_new_region(req);
> 
> Are we losing the check here? Before this change, the region had to be `FREE` _and_ the generation affiliated with the request had to have `free_unaffiliated_regions`.

I was confused about this part, if we can find a FREE region in the partition, why we still need to test if the generation must have free_unaffiliated_regions, I can add can_allocate_in_new_region back to retain the original behavior.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28036#discussion_r2481808233


More information about the hotspot-gc-dev mailing list