RFR: 8255234: ZGC: Bulk allocate forwarding data structures
Per Liden
pliden at openjdk.java.net
Fri Oct 23 07:53:36 UTC 2020
On Thu, 22 Oct 2020 14:58:24 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:
>> Allocation of forwarding data structures (ZForwarding/ZForwardingEntry instances) can generate a lot of calls to new/malloc if the number of pages in the relocation set is large. This can make the "Concurrent Select Relocation Set" phase long. By bulk allocating a single piece of memory and then placement new() all objects into that memory we can speed this phase up quite a bit.
>>
>> During relocation set selection we keep track of the number of ZForwardingEntry instances we will need for the selected relocation set. The ZForwardingAllocator is then initialized to have enough room for all the relocation set array, all ZForwarding instances, and all ZForwardingEntry instances. Objects are then placement new()'d using into the memory allocated by the ZForwardingAllocator.
>>
>> This patch was joint work with Albert (ayang).
>
> src/hotspot/share/gc/z/zRelocationSet.cpp line 70:
>
>> 68:
>> 69: void ZRelocationSet::reset() {
>> 70: _nforwardings = 0;
>
> This is not needed, right? `_nforwardings` will be properly reset in `populate`.
Yes, this is strictly not needed. But even if the backing memory is still there, the relocation set is conceptually reset here. For example, RelocationSetIterator should not return any forwardings after this point.
> src/hotspot/share/gc/z/zForwardingAllocator.inline.hpp line 38:
>
>> 36: // Not enough space left
>> 37: return NULL;
>> 38: }
>
> This allocator should never return null; better use assert.
Yep, good point. Will fix.
> src/hotspot/share/gc/z/zRelocationSet.cpp line 66:
>
>> 64:
>> 65: // Update statistics
>> 66: ZStatRelocation::set_at_populate_relocation_set(_allocator.size());
>
> Instead of `_allocator.size()`, one could use the same arg of `_allocator.reset()`, which is already known in this scope.
Sure, I can change that.
-------------
PR: https://git.openjdk.java.net/jdk/pull/804
More information about the hotspot-gc-dev
mailing list