RFR: 8343789: Move mutable nmethod data out of CodeCache

Dean Long dlong at openjdk.org
Fri Nov 22 02:46:18 UTC 2024


On Tue, 1 Oct 2024 02:10:37 GMT, Boris Ulasevich <bulasevich at openjdk.org> wrote:

> This change relocates mutable data (such as relocations, oops, and metadata) from the nmethod. The change follows the recent PR #18984, which relocated immutable nmethod data from the CodeCache.
> 
> The core idea remains the same: use the CodeCache for executable code while moving additional data to the C heap. The primary motivations are improving security and enhancing code density.
> 
> Although performance is not the main focus, testing on AArch64 CPUs, where code density plays a significant role, has shown a 1–2% performance improvement in specific scenarios, such as the CodeCacheStress test and the Renaissance Dotty benchmark.
> 
> The numbers. Immutable data constitutes **~30%** on the nmehtod. Mutable data constitutes **~8%** of nmethod. Example (statistics collected on the CodeCacheStress benchmark):
> - nmethod_count:134000, total_compilation_time: 510460ms
> - total allocation time malloc_mutable/malloc_immutable/CodeCache_alloc: 62ms/114ms/6333ms,
> - total allocation size (mutable/immutable/nmentod): 64MB/192MB/488MB
> 
> Functional testing: jtreg on arm/aarch/x86.
> Performance testing: renaissance/dacapo/SPECjvm2008 benchmarks.
> 
> Alternative solution (see comments): In the future, relocations can be moved to _immutable_data.

src/hotspot/share/code/codeBlob.cpp line 103:

> 101:   // The mutable_data_size is either calculated by the nmethod constructor to account
> 102:   // for reloc_info and additional data, or it is set here to accommodate only the relocation data.
> 103:   _mutable_data_size = (mutable_data_size == 0) ? cb->total_relocation_size() : mutable_data_size;

This seems strange to treat relocations as special.  Wouldn't it be better to have the caller always pass in the correct value?

src/hotspot/share/code/codeBlob.hpp line 108:

> 106: 
> 107:   int      _size;                  // total size of CodeBlob in bytes
> 108:   int      _relocation_size;       // size of relocation (could be bigger than 64Kb)

For offsets into the external mutable/immutable data, we could reduce codecache footprint further by moving these into a a header section of the external data block.  That also allows those blocks to be self-describing, which could help with error reporting or debugging.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21276#discussion_r1853209930
PR Review Comment: https://git.openjdk.org/jdk/pull/21276#discussion_r1853211488


More information about the hotspot-compiler-dev mailing list