Re: RFR: 8331087: Move immutable nmethod data from CodeCache

2024-04-27 Thread Vladimir Kozlov
On Fri, 26 Apr 2024 21:16:03 GMT, Vladimir Kozlov  wrote:

> Move immutable nmethod's data from CodeCache to C heap. It includes 
> `dependencies, nul_chk_table, handler_table, scopes_pcs, scopes_data, 
> speculations, jvmci_data`. It amounts for about 30% (optimized VM) of space 
> in CodeCache.
> 
> Use HotSpot's `os::malloc()` to allocate memory in C heap for immutable 
> nmethod's data. Bail out compilation if allocation failed.
> 
> Shuffle fields order and change some fields size from 4 to 2 bytes to avoid 
> nmethod's header size increase.
> 
> Tested tier1-5, stress,xcomp
> 
> Our performance testing does not show difference.
> 
> Example of updated `-XX:+PrintNMethodStatistics` output is in JBS comment.

@dean-long and @dougxc  

I am thinking may be I should not bailout  when `malloc` (or other space 
reservation in a future) failed to allocate memory for immutable data. But 
instead increase nmethod size and put immutable data there (as before).  Then 
we bailout only when CodeCache is full as before and we don't need 
`out_of_memory` failure reason. May be only record that in logs (when they are 
enabled).

What do you think?

-

PR Comment: https://git.openjdk.org/jdk/pull/18984#issuecomment-2081297482


Re: RFR: 8331087: Move immutable nmethod data from CodeCache

2024-04-27 Thread Vladimir Kozlov
On Sat, 27 Apr 2024 20:48:38 GMT, Doug Simon  wrote:

>> Move immutable nmethod's data from CodeCache to C heap. It includes 
>> `dependencies, nul_chk_table, handler_table, scopes_pcs, scopes_data, 
>> speculations, jvmci_data`. It amounts for about 30% (optimized VM) of space 
>> in CodeCache.
>> 
>> Use HotSpot's `os::malloc()` to allocate memory in C heap for immutable 
>> nmethod's data. Bail out compilation if allocation failed.
>> 
>> Shuffle fields order and change some fields size from 4 to 2 bytes to avoid 
>> nmethod's header size increase.
>> 
>> Tested tier1-5, stress,xcomp
>> 
>> Our performance testing does not show difference.
>> 
>> Example of updated `-XX:+PrintNMethodStatistics` output is in JBS comment.
>
> src/hotspot/share/code/nmethod.hpp line 476:
> 
>> 474: passed,
>> 475: code_cache_full,
>> 476: out_of_memory
> 
> Maybe `out_of_c_heap_memory` would be clearer? Or 
> `out_of_immutable_data_memory` if immutable data may not always be malloc'ed.

May be `no_space_for_immutable_data`.

-

PR Review Comment: https://git.openjdk.org/jdk/pull/18984#discussion_r1581998799


Re: RFR: 8331087: Move immutable nmethod data from CodeCache

2024-04-27 Thread Doug Simon
On Fri, 26 Apr 2024 21:16:03 GMT, Vladimir Kozlov  wrote:

> Move immutable nmethod's data from CodeCache to C heap. It includes 
> `dependencies, nul_chk_table, handler_table, scopes_pcs, scopes_data, 
> speculations, jvmci_data`. It amounts for about 30% (optimized VM) of space 
> in CodeCache.
> 
> Use HotSpot's `os::malloc()` to allocate memory in C heap for immutable 
> nmethod's data. Bail out compilation if allocation failed.
> 
> Shuffle fields order and change some fields size from 4 to 2 bytes to avoid 
> nmethod's header size increase.
> 
> Tested tier1-5, stress,xcomp
> 
> Our performance testing does not show difference.
> 
> Example of updated `-XX:+PrintNMethodStatistics` output is in JBS comment.

src/hotspot/share/jvmci/jvmciRuntime.cpp line 2178:

> 2176: 
> nmethod_mirror_name,
> 2177: 
> failed_speculations);
> 2178:   nmethod::ResultStatus result_status;

Please propagate the new `out_of_memory` result throughout JVMCI (e.g. in 
`JVMCI::CodeInstallResult` enum and 
`HotSpotVMConfig.getCodeInstallResultDescription` method).

-

PR Review Comment: https://git.openjdk.org/jdk/pull/18984#discussion_r1581906300


Re: RFR: 8331087: Move immutable nmethod data from CodeCache

2024-04-27 Thread Doug Simon
On Fri, 26 Apr 2024 21:16:03 GMT, Vladimir Kozlov  wrote:

> Move immutable nmethod's data from CodeCache to C heap. It includes 
> `dependencies, nul_chk_table, handler_table, scopes_pcs, scopes_data, 
> speculations, jvmci_data`. It amounts for about 30% (optimized VM) of space 
> in CodeCache.
> 
> Use HotSpot's `os::malloc()` to allocate memory in C heap for immutable 
> nmethod's data. Bail out compilation if allocation failed.
> 
> Shuffle fields order and change some fields size from 4 to 2 bytes to avoid 
> nmethod's header size increase.
> 
> Tested tier1-5, stress,xcomp
> 
> Our performance testing does not show difference.
> 
> Example of updated `-XX:+PrintNMethodStatistics` output is in JBS comment.

src/hotspot/share/code/nmethod.hpp line 476:

> 474: passed,
> 475: code_cache_full,
> 476: out_of_memory

Maybe `out_of_c_heap_memory` would be clearer? Or 
`out_of_immutable_data_memory` if immutable data may not always be malloc'ed.

-

PR Review Comment: https://git.openjdk.org/jdk/pull/18984#discussion_r1581904919