RFR: 8343789: Move mutable nmethod data out of CodeCache

Boris Ulasevich bulasevich at openjdk.org
Thu Nov 21 14:17:49 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.

@vnkozlov Hi Vladimir,
What do you think about the idea of ​​moving relocInfo data out of nmethod additionally to recent [Move immutable nmethod data from CodeCache](https://github.com/openjdk/jdk/pull/18984)? It would reduce the CodeHeap fill by 5%.

Performance update. On an aarch machine the CodeCacheStress benchmark shows a 1-2% performance improvement with this change,

Statistics on the CodeCacheStress benchmark with high numberOfClasses-instanceCount-rangeOfClasses parameter values:
- 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

-XX:+PrintNMethodStatistics


Statistics for 21032 bytecoded nmethods for C1:
 total size      = 120722408 (100%)
 in CodeCache    = 79358808 (65.736603%)
   header        = 5215936 (6.572599%)
   constants     = 320 (0.000403%)
   main code     = 69017912 (86.969444%)
   stub code     = 5124640 (6.457557%)
 mutable data    = 10488856 (8.688409%)
   relocation    = 6573064 (62.667118%)
   oops          = 515680 (4.916456%)
   metadata      = 3400112 (32.416424%)
 immutable data  = 30874744 (25.574991%)
   dependencies  = 636240 (2.060714%)
   nul chk table = 756920 (2.451583%)
   handler table = 180456 (0.584478%)
   scopes pcs    = 16052608 (51.992683%)
   scopes data   = 13248520 (42.910542%)
Statistics for 8171 bytecoded nmethods for C2:
 total size      = 64948664 (100%)
 in CodeCache    = 25580504 (39.385727%)
   header        = 2026408 (7.921689%)
   constants     = 448 (0.001751%)
   main code     = 20925472 (81.802422%)
   stub code     = 2628176 (10.274137%)
 mutable data    = 6572064 (10.118859%)
   relocation    = 3406216 (51.828709%)
   oops          = 305912 (4.654733%)
   metadata      = 2859936 (43.516556%)
 immutable data  = 32796096 (50.495411%)
   dependencies  = 926992 (2.826532%)
   nul chk table = 537024 (1.637463%)
   handler table = 1695568 (5.170030%)
   scopes pcs    = 15451968 (47.115265%)
   scopes data   = 14184544 (43.250710%)

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

PR Comment: https://git.openjdk.org/jdk/pull/21276#issuecomment-2391711138
PR Comment: https://git.openjdk.org/jdk/pull/21276#issuecomment-2476420926
PR Comment: https://git.openjdk.org/jdk/pull/21276#issuecomment-2491100267


More information about the hotspot-compiler-dev mailing list