RFR: 8048180: Eager reclaim of humongous objects with references [v4]

Albert Mingkun Yang ayang at openjdk.org
Thu Oct 9 12:52:19 UTC 2025


On Thu, 9 Oct 2025 12:39:53 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

>> Hi all,
>> 
>>   please review this change to G1 that enables eager reclaim of humongous objects with references, either objArrays or just really large objects.
>> 
>> It works the same as other humongous object's eager reclaim, with the caveat that I disabled it during concurrent mark to avoid problems with SATB. There is fairly extensive documentation about why I think this works, and how in the comment in `g1YoungCollector.cpp`.
>> 
>> The test case exhaustively tests all combinations of when a particular type of object should be able to be reclaimed depending on when it is allocated (only for `typeArray` and `objArray` - huge objects work the same as the latter).
>> 
>> I added a diagnostic flag `G1EagerReclaimWithRefs` to allow disabling this particular functionality for diagnostic purposes, but I think it's not really necessary, and I'm open to remove it.
>> 
>> The following screenshot shows pause times before (purple) and after (brown) of one of the [Optaplanner](https://www.optaplanner.org/blog/2021/09/15/HowMuchFasterIsJava17.html) benchmarks as a result of this change.
>>  
>> <img width="702" height="485" alt="Screenshot 2025-09-26 at 13 59 05" src="https://github.com/user-attachments/assets/995e9e27-f861-44bd-8ced-3bd952e314e8" />
>> 
>> Testing: new test cases, gha, tier1-5
>> 
>> Thanks,
>>   Thomas
>
> Thomas Schatzl has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
> 
>  - Merge branch 'master' into 8048180-investigate-eager-reclaim-of-reference-arrays
>  - * more documentation work
>  - * walulyai review, improved comments, example
>  - * also check for actual region reclamation
>    
>    * enable reference array reclaim anywhere during non-marking, enable during rebuild
>    
>    * additional test for all situation
>    
>    * fix guarantee for humongous regular objects
>    
>    * need to clear card table of eagerly reclaimed regions
>    
>    * do not redirty recently freed humongous regions to avoid stray card marks
>    
>    * card table of humongous-continues regions has not been cleared
>    
>    * some cleanup
>    
>    * include non-typeArrays allocated after mark start in candidates
>    * and allow non-typeArray candidates right after marking completed
>    
>    * update test case to also check allocations after marking
>    * additional documentation
>    
>    * rename test case
>    
>    * more explanations
>    
>    * move back free humongous regions to post evacuate 2. There does not seem to be a reason to put it there, and it clashes with RecalculateUsedTask.

Maybe the title should have `G1: ` prefix?

src/hotspot/share/gc/g1/g1YoungCollector.cpp line 401:

> 399:       bool mark_in_progress = _g1h->collector_state()->mark_in_progress();
> 400:       return (obj->is_typeArray() || (G1EagerReclaimWithRefs && (allocated_after_mark_start || !mark_in_progress))) &&
> 401:              _g1h->is_potential_eager_reclaim_candidate(region);

I'd suggest rewriting this a bit (e.g. using early-return or sth) -- the current form is not super clear.

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

PR Review: https://git.openjdk.org/jdk/pull/27525#pullrequestreview-3318815681
PR Review Comment: https://git.openjdk.org/jdk/pull/27525#discussion_r2416688088


More information about the hotspot-gc-dev mailing list