RFR: 8262185: G1: Prune collection set candidates early

Ivan Walulya iwalulya at openjdk.java.net
Wed Feb 24 12:59:40 UTC 2021


On Tue, 23 Feb 2021 14:07:33 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

> Hello,
> 
>   can I have reviews for this change to the collection candidate selection procedure, moving the G1HeapWastePercent exclusion criteria right after candidate selection instead of at the end of mixed gcs?
> 
> This can save lots of memory with negligible other impact.
> 
> Long version:
> Currently G1 maintains collection set candidates from the marking phase (where it determines those) until the end of the mixed gc phase.
> 
> Mixed gc phase ends when the amount of space that can be reclaimed in the java heap with the remaining collection set candidates is smaller than G1HeapWastePercent of the (current) heap capacity.
> 
> This means that in some cases a significant amount of memory is used for regions that will never be evacuated. In addition to that, maintaining the remembered sets for these never evacuated regions uses execution time and more memory for the remembered set.
> 
> In fact, in some cases, it can happen that in the first few mixed gcs of a mixed gc phase, remembered set memory consumption *increases* even though the remembered sets of recently evacuated old gen regions are freed.
> 
> The proposed alternative is to prune the collection set candidates as early as possible, filtering out regions that are never going to be evacuated (or have a very low probability).
> 
> In some cases doing this can save half of peak remembered set memory usage. 
> 
> There are a few drawbacks here that should be considered during evaluation, also comparing against the old heuristic.
> 
> * In the old heuristic, G1 checks *at the end* of gc whether the remaining collection set candidates are worth collecting (remaining collectible space < G1HeapWastePercent means: stop). Which helps with ensuring at least some forward progress in evacuating the heap because (assuming there are candidates) at least some space will be reclaimed.
> (I do not know whether this behavior as is is intentional for that reason, but it has been there since initial implementation; then it did not really matter because G1 has been maintaining the old gen remembered sets for all regions all the time anyway).
> This is approximated by not removing all of the candidates to have at least one "minimal" mixed collection in this change.
> 
> * In some cases in the old heuristic G1 would just evacuate all candidate regions (in the extreme in a single gc) if the pause time permitted, reclaiming a bit more space (i.e. that amount < G1HeapWastePercent of the total heap).
> You would expect (given the default value of 5), there will be more mixed cycles because of that with the new heuristic. 
> 
> Testing: tier1-5, Oracle internal performance test suite
> 
> Thanks,
>   Thomas

Lgtm!

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

Marked as reviewed by iwalulya (Committer).

PR: https://git.openjdk.java.net/jdk/pull/2693



More information about the hotspot-gc-dev mailing list