RFR: 8294775: Shenandoah: reduce contention on _threads_in_evac [v4]

Aleksey Shipilev shade at openjdk.org
Mon Nov 14 15:15:28 UTC 2022


On Mon, 14 Nov 2022 14:43:12 GMT, Nick Gasson <ngasson at openjdk.org> wrote:

>> The idea here is to reduce contention on the shared `_threads_in_evac` counter by splitting its state over multiple independent cache lines. Each thread hashes to one particular counter based on its `Thread*`. This helps improve throughput of concurrent evacuation where many Java threads may be attempting to update this counter on the load barrier slow path.
>> 
>> See this earlier thread for details and SPECjbb results: https://mail.openjdk.org/pipermail/shenandoah-dev/2022-October/017494.html
>> 
>> Also tested `hotspot_gc_shenandoah` on x86 and AArch64.
>
> Nick Gasson 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 8294775
>  - Put the * next to the type
>  - Refactor
>  - 8294775: Shenandoah: reduce contention on _threads_in_evac

This looks fine to me with minor nits.

src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.cpp line 35:

> 33: 
> 34: ShenandoahEvacOOMCounter::ShenandoahEvacOOMCounter()
> 35:   : _bits(0) {

`:` should remain on the same line.

src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.cpp line 93:

> 91:   _threads_in_evac = NEW_C_HEAP_ARRAY(ShenandoahEvacOOMCounter, _num_counters, mtGC);
> 92:   for (int i = 0; i < _num_counters; i++) {
> 93:     new (&_threads_in_evac[i]) ShenandoahEvacOOMCounter;

Suggestion:

    new (&_threads_in_evac[i]) ShenandoahEvacOOMCounter();

src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.cpp line 119:

> 117: ShenandoahEvacOOMCounter* ShenandoahEvacOOMHandler::counter_for_thread(Thread* t) {
> 118:   const uint64_t key = hash_pointer(t);
> 119:   assert(is_power_of_2(_num_counters), "must be");

I suggest asserting this once in constructor, to make debug builds faster.

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

Marked as reviewed by shade (Reviewer).

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


More information about the hotspot-gc-dev mailing list