Integrated: 8332139: SymbolTableHash::Node allocations allocates twice the required memory
Axel Boldt-Christmas
aboldtch at openjdk.org
Wed Jun 12 14:09:22 UTC 2024
On Mon, 13 May 2024 12:30:38 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:
> The symbols are inline and allocated together with the ConcurrentHashTable (CHT) Nodes. The calculation used for the required size is `alloc_size = size + value.byte_size() + value.effective_length();`
>
> Where
> * `size == sizeof(SymbolTableHash::Node) == sizeof(void*) + sizeof(Symbol)`
> * `value.byte_size() == dynamic_sizeof(Symbol) == sizeof(Symbol) + <bytes beyond object>`
> * `value.effective_length() == dynamic_sizeof(Symbol) - sizeof(Symbol) == <bytes beyond object>`
>
> So `alloc_size` ends up being `sizeof(void*) /* node metadata */ + 2 * dynamic_sizeof(Symbol)`
>
> Because using the CHT with dynamically sized (and inlined) types requires knowing about its implementation details I chose to make the functionality for calculating the the allocation size a property of the CHT. It now queries the CHT for the node allocation size given the dynamic size required for the VALUE.
>
> The only current (implicit) restriction regarding using dynamically sized (and inlined) types in CHT is that the _value field C++ object ends where the Node object ends, so there is not padding bytes where the dynamic payload is allocated. (effectively `sizeof(VALUE) % alignof(Node) == 0` as long as there are no non-standard alignment fields in the Node metadata). I chose to test this as a runtime assert that the _value ends where the Node object ends, instead of a static assert with the alignment as it seemed to more explicitly show the intent of the check.
>
> Running testing tier1-7
This pull request has now been integrated.
Changeset: 2c1da6c6
Author: Axel Boldt-Christmas <aboldtch at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/2c1da6c6fa2e50856ea71c0e266961171bee1037
Stats: 22 lines in 4 files changed: 17 ins; 2 del; 3 mod
8332139: SymbolTableHash::Node allocations allocates twice the required memory
Reviewed-by: iwalulya, coleenp
-------------
PR: https://git.openjdk.org/jdk/pull/19214
More information about the hotspot-dev
mailing list