RFR: 8264424: Support OopStorage bulk allocation

Albert Mingkun Yang ayang at openjdk.java.net
Tue Apr 6 09:54:13 UTC 2021


On Tue, 30 Mar 2021 11:55:59 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

> Please review this change to OopStorage to support bulk allocation.  A new overload for allocate is provided:
> size_t allocate(oop** entries, size_t size)
> The approach taken is to claim all of the available entries in the first available block, add as many of those entries as will fit in the buffer, and release any remaining entries back to the block.  Only the claim part needs to be done while holding the allocation mutex.  This is is optimized for clients that want more than just a couple entries, and minimizes time under the lock.  The maximum number of entries (the number of entries in a block) is provided as a constant for sizing requests, to avoid the release of unrequested entries.  An application that wants more than that, or a specific number that might not be available from the next block, needs to make multiple bulk allocation calls, but that's still going to be much faster than one at a time allocations.
> 
> Testing:
> mach5 tier1
> New gtest for bulk allocation.
> I've been using this for a while as part of another in-development change that makes heavy use of this feature.

Marked as reviewed by ayang (Committer).

src/hotspot/share/gc/shared/oopStorage.cpp line 478:

> 476:     block = block_for_allocation();
> 477:     if (block == NULL) return 0; // Block allocation failed.
> 478:     // Take exclusive use of this block for allocation.

Maybe "Taking all remaining entries, so remove from list."? The "exclusive use" is ensured by the above `MutexLocker`, not `unlink`.

src/hotspot/share/gc/shared/oopStorage.hpp line 119:

> 117:   // Allocates multiple entries, returning them in the ptrs buffer.  The
> 118:   // number of entries that will be allocated is never more than the minimum
> 119:   // of size and bulk_allocate_limit, but may be less than either.  Possibly

It took me a few seconds to understand this sentence. Maybe replace it with "postcondition: result <= min(size, bulk_allocate_limit)" below?

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

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



More information about the hotspot-gc-dev mailing list