openj9 icon indicating copy to clipboard operation
openj9 copied to clipboard

Avoid touching the SCC as much as possible during stack walk

Open gacholio opened this issue 6 months ago • 11 comments

Cache localmap/stackmap/argbits to avoid walking bytecodes.

Related: #21812

This feature is disabled by default. Enable with -XX:+CacheMaps

gacholio avatar May 28 '25 20:05 gacholio

@dmitripivkine Please take a look at the GC changes. What I intend is to flush the appropriate class loader cache when a class is unloaded. I may have the flush a bit too deep if classes can only be unloaded when their loaded is unloaded. What about anon classes? IIRC, they get unloaded piecemeal.

gacholio avatar Jun 02 '25 16:06 gacholio

@dmitripivkine Please take a look at the GC changes. What I intend is to flush the appropriate class loader cache when a class is unloaded. I may have the flush a bit too deep if classes can only be unloaded when their loaded is unloaded. What about anon classes? IIRC, they get unloaded piecemeal.

Classes are unloaded on class loader basis (except Anonymous), there is no case some classes can be unloaded but entire class loader not. So I think flushing should be done once. I assume it should be done before class loader unloading (cleanup).

Anonymous classes can be unloaded individually, but there is a trick. Anonymous class loader is just technical storage for Anonymous classes (and it can not be unloaded by design). Each Anonymous class however has pointer to its parent class loader (not an Anonymous one).

dmitripivkine avatar Jun 02 '25 17:06 dmitripivkine

Each Anonymous class however has pointer to it's parent class loader (not an Anonymous one).

Which loader appears in an anon class classLoader field of the J9Class? That's the loader I need to flush on anon class unload.

I think for normal class loaders, I do not need any GC changes (freeing the loader will free the caches as well).

gacholio avatar Jun 03 '25 13:06 gacholio

Which loader appears in an anon class classLoader field of the J9Class? That's the loader I need to flush on anon class unload.

I know classLoader field for Anonymous class points to regular class loader which is "logical parent" of this class. Sorry, I don't know details. In order to get list of unloaded Anonymous classes you can subscribe to J9HOOK_VM_ANON_CLASSES_UNLOAD hook and walk provided list. Alternatively you can call function from GC code from addDyingClassesToList() is the case class loader passed as parameter is _javaVM->anonClassLoader.

dmitripivkine avatar Jun 03 '25 14:06 dmitripivkine

you can subscribe to J9HOOK_VM_ANON_CLASSES_UNLOAD hook

The VM already hooks this, so I'll remove the GC changes and put the flush in the existing loop.

gacholio avatar Jun 03 '25 15:06 gacholio

I've made the class unload changes as discussed and optimized the HCR path so only the loaders of redefined classes are flushed, rather than all of them. The outer stackwalk loop has been modified to not always read from the bytecodes to check fore impdep2.

gacholio avatar Jun 03 '25 20:06 gacholio

jenkins compile xlinux jdk17

tajila avatar Jun 10 '25 15:06 tajila

Fixing the failure.

gacholio avatar Jun 10 '25 18:06 gacholio

jenkins compile xlinux jdk17

gacholio avatar Jun 10 '25 20:06 gacholio

Thanks GAC, we are going to do some perf runs on it.

tajila avatar Jun 11 '25 13:06 tajila

jenkins compile xlinux jdk17

gacholio avatar Jun 16 '25 14:06 gacholio

jenkins test sanity.functional win jdk8

tajila avatar Jun 17 '25 14:06 tajila

jenkins test amac sanity,extended.functional amac jdk17

tajila avatar Jun 17 '25 14:06 tajila

jenkins test sanity,extended.functional amac jdk17

gacholio avatar Jun 17 '25 16:06 gacholio

Consistent crash here:

14:17:41  Unhandled exception
14:17:41  Type=Segmentation error vmState=0x00000000
14:17:41  J9Generic_Signal_Number=00000018 Signal_Number=0000000b Error_Value=00000000 Signal_Code=00000002
14:17:41  Handler1=0000000104E8DC9C Handler2=0000000104B86318 InaccessibleAddress=FFFFFFFFFFFFFFF8
14:17:41  x0=0000600000F243E0 x1=0000000000000000 x2=0000000000000000 x3=000000013903297C
14:17:41  x4=000000017EF7D160 x5=0000000000000000 x6=000000000000006D x7=000000017EF7D228
14:17:41  x8=0000000000000000 x9=0000000000000000 x10=00000001228513F0 x11=000000017EF7D1A0
14:17:41  x12=0000000000000000 x13=0000000000000000 x14=000000017EF7D770 x15=0000000000000000
14:17:41  x16=000000019162EA10 x17=00000002035AA6F0 x18=0000000149076B00 x19=0000000149076B00
14:17:41  x20=0000000149076E58 x21=00000001056FC278 x22=00000001228513D0 x23=0000000104FC26EA
14:17:41  x24=0000000149076DF8 x25=00000000102C0810 x26=0000000104FCE454 x27=0000000104FB751D
14:17:41  x28=0000000000000000 x29(FP)=000000017EF7D220 x30(LR)=0000000104EC54B0 x31(SP)=000000017EF7D160
14:17:41  PC=0000000104EC608C SP=000000017EF7D160
14:17:41  v0=0000000360208ee0 (f: 1612746496.000000, d: 7.162790e-314)
14:17:41  v1=0000000000000000 (f: 0.000000, d: 0.000000e+00)
14:17:41  v2=0706050403020100 (f: 50462976.000000, d: 7.949929e-275)
14:17:41  v3=000000610000006a (f: 106.000000, d: 2.058336e-312)
14:17:41  v4=373cd4c5ab654ba8 (f: 2875542528.000000, d: 1.292833e-42)
14:17:41  v5=000000004b018f79 (f: 1258393472.000000, d: 6.217290e-315)
14:17:41  v6=94446f0194446f01 (f: 2487512832.000000, d: -4.855772e-211)
14:17:41  v7=000e1781000e1781 (f: 923521.000000, d: 1.959708e-308)
14:17:41  v8=000003c10000745f (f: 29791.000000, d: 2.039238e-311)
14:17:41  v9=0000000000000000 (f: 0.000000, d: 0.000000e+00)
14:17:41  v10=0000000000000000 (f: 0.000000, d: 0.000000e+00)
14:17:41  v11=0000000000000000 (f: 0.000000, d: 0.000000e+00)
14:17:41  v12=0000000000000000 (f: 0.000000, d: 0.000000e+00)
14:17:41  v13=0000000000000000 (f: 0.000000, d: 0.000000e+00)
14:17:41  v14=0000000000000000 (f: 0.000000, d: 0.000000e+00)
14:17:41  v15=0000000000000000 (f: 0.000000, d: 0.000000e+00)
14:17:41  v16=bfd0000000000000 (f: 0.000000, d: -2.500000e-01)
14:17:41  v17=3fd54347b9e77555 (f: 3118953728.000000, d: 3.322315e-01)
14:17:41  v18=3f720373bc053116 (f: 3154456832.000000, d: 4.397823e-03)
14:17:41  v19=3fe62e42fefa39ef (f: 4277811712.000000, d: 6.931472e-01)
14:17:41  v20=0000000000000000 (f: 0.000000, d: 0.000000e+00)
14:17:41  v21=0000000000000000 (f: 0.000000, d: 0.000000e+00)
14:17:41  v22=0000000000000000 (f: 0.000000, d: 0.000000e+00)
14:17:41  v23=0000000000000000 (f: 0.000000, d: 0.000000e+00)
14:17:41  v24=0000000000000000 (f: 0.000000, d: 0.000000e+00)
14:17:41  v25=0000000000000000 (f: 0.000000, d: 0.000000e+00)
14:17:41  v26=0000000000000000 (f: 0.000000, d: 0.000000e+00)
14:17:41  v27=0000000000000000 (f: 0.000000, d: 0.000000e+00)
14:17:41  v28=0000000000000000 (f: 0.000000, d: 0.000000e+00)
14:17:41  v29=0000000000000000 (f: 0.000000, d: 0.000000e+00)
14:17:41  v30=6974752e6176616a (f: 1635148160.000000, d: 9.787117e+199)
14:17:41  v31=76616a4c293b7265 (f: 691761792.000000, d: 1.713702e+262)
14:17:41  Module=/Users/jenkins/workspace/Test_openjdk17_j9_sanity.openjdk_aarch64_mac_Personal_testList_2/jdkbinary/j2sdk-image/lib/default/libj9vm29.dylib
14:17:41  Module_base_address=0000000104E68000 Symbol=walkStackFrames
14:17:41  Symbol_address=0000000104EC540C
14:17:41  Target=2_90_20250618_788 (Mac OS X 15.3.1)
14:17:41  CPU=aarch64 (8 logical CPUs) (0x400000000 RAM)
14:17:41  ----------- Stack Backtrace -----------
14:17:41  ---------------------------------------
14:17:41  JVMDUMP039I Processing dump event "gpf", detail "" at

tajila avatar Jun 18 '25 13:06 tajila

Failures seem to be related to use of the StackWalker class.

gacholio avatar Jun 19 '25 18:06 gacholio

jenkins line endings check

gacholio avatar Jun 23 '25 18:06 gacholio

jenkins test sanity,extended.functional xlinux jdk17

gacholio avatar Jun 23 '25 18:06 gacholio

jenkins test sanity,extended.functional zlinux jdk21

gacholio avatar Jun 23 '25 18:06 gacholio