RFR: 8343789: Move mutable nmethod data out of CodeCache [v6]
Tobias Hartmann
thartmann at openjdk.org
Tue Jan 14 09:12:51 UTC 2025
On Mon, 16 Dec 2024 16:59:57 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.
>
> Boris Ulasevich has updated the pull request incrementally with one additional commit since the last revision:
>
> removing dead code
I see this failure in our testing with an internal test:
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/workspace/open/src/hotspot/share/code/nmethod.cpp:1513), pid=1863674, tid=1863692
# assert(static_cast<int>(_metadata_offset) == reloc_size + oop_size) failed: failed: 21744 != 87280
Current CompileTask:
C2:61370 3693 b 4 org.apache.lucene.analysis.en.KStemData1::<clinit> (27623 bytes)
Stack: [0x00007f3acf3f5000,0x00007f3acf4f5000], sp=0x00007f3acf4f0a50, free space=1006k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x14d9151] nmethod::nmethod(Method*, CompilerType, int, int, int, int, int, unsigned char*, CodeOffsets*, int, DebugInformationRecorder*, Dependencies*, CodeBuffer*, int, OopMapSet*, ExceptionHandlerTable*, ImplicitExceptionTable*, AbstractCompiler*, CompLevel, char*, int, JVMCINMethodData*)+0x981 (nmethod.cpp:1513)
V [libjvm.so+0x14d94df] nmethod::new_nmethod(methodHandle const&, int, int, CodeOffsets*, int, DebugInformationRecorder*, Dependencies*, CodeBuffer*, int, OopMapSet*, ExceptionHandlerTable*, ImplicitExceptionTable*, AbstractCompiler*, CompLevel, char*, int, JVMCINMethodData*)+0x22f (nmethod.cpp:1200)
V [libjvm.so+0x926cb4] ciEnv::register_method(ciMethod*, int, CodeOffsets*, int, CodeBuffer*, int, OopMapSet*, ExceptionHandlerTable*, ImplicitExceptionTable*, AbstractCompiler*, bool, bool, bool, bool, int)+0x4c4 (ciEnv.cpp:1063)
V [libjvm.so+0x157b0d5] PhaseOutput::install_code(ciMethod*, int, AbstractCompiler*, bool, bool)+0x125 (output.cpp:3443)
V [libjvm.so+0xa54d02] Compile::Code_Gen()+0x612 (compile.cpp:3033)
V [libjvm.so+0xa579cf] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1c6f (compile.cpp:885)
V [libjvm.so+0x89f495] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1d5 (c2compiler.cpp:142)
V [libjvm.so+0xa63a88] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x928 (compileBroker.cpp:2319)
V [libjvm.so+0xa647c8] CompileBroker::compiler_thread_loop()+0x528 (compileBroker.cpp:1977)
V [libjvm.so+0xf3478e] JavaThread::thread_main_inner()+0xee (javaThread.cpp:777)
V [libjvm.so+0x1880536] Thread::call_run()+0xb6 (thread.cpp:232)
V [libjvm.so+0x155a188] thread_native_entry(Thread*)+0x128 (os_linux.cpp:860)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/21276#issuecomment-2589382812
More information about the hotspot-compiler-dev
mailing list