RFR: 8273626: G1: refactor G1CardSetAllocator to support element size less pointer size

Thomas Schatzl tschatzl at openjdk.java.net
Thu Sep 23 14:08:54 UTC 2021


On Sat, 11 Sep 2021 05:05:47 GMT, Hamlin Li <mli at openjdk.org> wrote:

> To finish https://bugs.openjdk.java.net/browse/JDK-8254739, we need a segmented array to store a growing regions index array, in the initial version of that patch, a newly home made segmented array was used, but the memory efficiency is not as good as expected, G1CardSetAllocator is a potential candidate to fullfill the requirement, but need some enhancement.
> 
> This is a try to enhance G1CardSetAllocator(and G1CardSetBuffer, G1CardSetBufferList) to support element size less pointer size, and strip this basic function as a more generic segmented array (G1SegmentedArray).

Sorry for the late reply. Coincidentally around release there's also some housekeeping to do.

My main question about this change is: Would it be possible to give a sneak-peek on the use of `G1SegmentedArray` in the [JDK-8254739](https://bugs.openjdk.java.net/browse/JDK-8254739) code? It is impossible to determine if the change fits the intended purpose, and I want to avoid changing `G1SegmentedArray` again later.

What *I* thought was that every region gets a set of elements using `G1SegmentedArray` attached to it, in whatever form. Multiple threads add to that at the same time.

This means that multiple threads might add new segments to it at the same time, meaning that they may try to append new segments to it. What happens with the thread and the segment that fails? Shouldn't this allocation be reused somehow (maybe for other segmented arrays?).

Also, this seems to drop the concurrent freeing of these segments after GC, which is nice too.

The remembered set uses the memory provided by the segmented arrays in chunks too, i.e. the `G1CardSetArray` container. Not sure if something like this would be more appropriate here instead of directly using the chunks (but may well be as good).

What are your plans about all this?

Depending on your design choices (which I do not know) this change may be reasonable or not. Please detail this a bit.

Also note that the CR title currently is a bit misleading imho, indicating a small change supporting smaller pointer sizes. I would prefer if it would be named something like "Factor out concurrent segmented array from G1CardSetAllocator".

src/hotspot/share/gc/g1/g1SegmentedArray.hpp line 27:

> 25: 
> 26: #ifndef LINUX_X86_64_SERVER_SLOWDEBUG_G1SEGMENTEDARRAY_HPP
> 27: #define LINUX_X86_64_SERVER_SLOWDEBUG_G1SEGMENTEDARRAY_HPP

This should be something like `SHARE_GC_G1_G1SEGMENTEDARRAY_HPP`

src/hotspot/share/gc/g1/g1SegmentedArray.hpp line 36:

> 34: // SegmentedArrayBuffers can be linked together using a singly linked list.
> 35: template<MEMFLAGS flag>
> 36: class SegmentedArrayBuffer : public CHeapObj<flag> {

Should be `G1SegmentedArrayBuffer`.

src/hotspot/share/gc/g1/g1SegmentedArray.hpp line 85:

> 83: 
> 84:   char* start() const { return _buffer; }
> 85: 

Unused, can be removed.

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

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



More information about the hotspot-gc-dev mailing list