RFR: 8260267: ZGC: Reduce mark stack usage [v3]

Stefan Johansson sjohanss at openjdk.java.net
Thu Apr 29 19:38:00 UTC 2021


On Thu, 29 Apr 2021 13:48:11 GMT, Per Liden <pliden at openjdk.org> wrote:

>> Under some conditions, striped marking can cause excessive mark stack memory usage. For example, when the object graph has one or more N:1 relations ships, where N is a large number.
>> 
>> To avoid pushing mark stack entries to already marked objects, and thus reduce mark stack memory usage, this patch adds does two things:
>>  * GC threads will under some conditions mark the object before pushing, else (if the condition to mark failed)
>>  * GC threads will check if the object is already marked before pushing.
>> 
>> The conditions for marking before pushing is:
>>  * We are using a single stripe, in which cases striped marking is essentially disabled anyway.
>>  * We see excessive mark stack usage. In other words, the mark stack allocator indicates "high usage".
>> 
>> To make this easier to review, this PR contains two commits:
>>  * `ZGC: Reduce mark stack usage` - This patch adds the infrastructure needed to mark before push, but only does so if we are using a single stripe.
>>  * `ZGC: Mark before push if mark stack usage is high` - This patch adds the condition to mark before push if the mark stack allocator indicates "high usage". As a bonus, this patch will also uncommit memory used for mark stacks after the marking has completed.
>> 
>> Testing:
>>  * Tier1-7
>>  * SPECjbb2015, score and marking times unaffected
>>  * casparcwang at tencent.com reports that this patch, in combination with PR #3455, solves the problem for Apache Zookeeper.
>
> Per Liden has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Review comments from StefanJ and Albert

Looks good, just two minor comments.

src/hotspot/share/gc/z/zMarkStackAllocator.cpp line 72:

> 70: 
> 71: static bool is_high_usage(size_t size) {
> 72:   // Consider usage to be high if we've used more than a 8th of the available space.

"a 8th" -> "an 8th" or "one 8th"

src/hotspot/share/gc/z/zMarkStackAllocator.cpp line 101:

> 99: 
> 100:   log_debug(gc, marking)("Expanding mark stack space: " SIZE_FORMAT "M->" SIZE_FORMAT "M (%s Usage)",
> 101:                          old_size / M, new_size / M, _high_usage ? "High" : "Low");

A bit strange to only have "Low" and "High" usage, maybe "Normal" and "High" would be more accurate.

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

Marked as reviewed by sjohanss (Reviewer).

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



More information about the hotspot-gc-dev mailing list