RFR: 8234328: VectorSet::clear can cause fragmentation

Nils Eliasson nils.eliasson at oracle.com
Wed Dec 11 13:46:31 UTC 2019


Hi Claes,

Your change looks good. Reviewed.

Regards,

Nils

On 2019-11-19 11:18, Claes Redestad wrote:
> Hi,
>
> today, VectorSet::clear "reclaims" storage when the size is large.
>
> However, since the backing array is allocated in a resource arena, this
> is dubious since the currently retained memory is only actually freed
> and made reusable if it's currently the last chunk of memory allocated
> in the arena. This means a clear() is likely to just waste the allocated
> memory until we exit the current resource scope
>
> Instead, I propose a strategy where instead of "freeing" we keep track
> of the currently allocated size of the VectorSet separately from the in-
> use size. We can then defer the memset to reset/clear the memory to the
> next time we need to grow, thus avoiding unnecessary reallocations and
> memsets. This limits the memory waste.
>
> Bug:    https://bugs.openjdk.java.net/browse/JDK-8234328
> Webrev: http://cr.openjdk.java.net/~redestad/8234328/open.00/
>
> Testing: tier1-3
>
> Either of reset() or clear() could now be removed, which seems like a
> straightforward follow-up RFE. With some convincing I could roll it into
> this patch.
>
> Thanks!
>
> /Claes


More information about the hotspot-compiler-dev mailing list