eclipse-openj9 / openj9

Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Other
3.28k stars 721 forks source link

Code cache marked prematurely full #20615

Open JamesKingdon opened 2 hours ago

JamesKingdon commented 2 hours ago

Java -version output

pap6480sr8fp30-20240801_01

Summary of problem

Customer running under FSD on Power with an agent reported 'hangs'. Investigation discovered that the system was just running very slowly, with all methods running in the interpreter after the agent late attaches and performs a few passes of class redefinition. On redef under FSD the code cache is cleared and all segments that are allocated at that time subsequently get marked as full due to lack of trampoline space. After the cache is emptied the segments are supposed to be empty, but we incorrectly reset the trampoline pointers to the end position instead of the start position. The problem was exacerbated because there is documentation online recommending the use of 32MB segments which the customer had followed. This made it more likely that all of the segments had already been allocated at the time the agent attached and redefined classes. As a result we emptied the code cache, marked all segments full and were subsequently unable to recompile any code.

Diagnostic files

The problem can be readily reproduced on a Power system with a suitable agent installed. Enabling jit verbose logging with hooks, codecache and compilePerf* options shows a sequence of

#HK:  vmThread=00000000004BB100 hook jitClassesRedefined 
#CODECACHE:  CodeCache 00007D4FB400AA30 marked as full in reserveSpaceForTrampoline
#PERF:  t=  9608 <WARNING: JIT CACHES FULL> Disable further compilation

Using a standard testcase where higher numbers are better shows an extreme case of the benefit of this change:

Before change:

threads   throughput
    1         121   
    2         113  
    3         144
    4          87

After change:

threads   throughput
    1         3762   
    2         9927  
    3        14924
    4        20597
github-actions[bot] commented 2 hours ago

Issue Number: 20615 Status: Open Recommended Components: comp:vm, comp:gc, comp:build

JamesKingdon commented 2 hours ago

Opened https://github.com/eclipse-openj9/openj9/pull/20614 for this issue.