Skip to content

Add SCC layer creation for JITServer AOT cache - #17945

Merged
mpirvu merged 1 commit into
eclipse-openj9:masterfrom
cjjdespres:late-layer-with-options-hack
Aug 25, 2023
Merged

Add SCC layer creation for JITServer AOT cache#17945
mpirvu merged 1 commit into
eclipse-openj9:masterfrom
cjjdespres:late-layer-with-options-hack

Conversation

@cjjdespres

@cjjdespres cjjdespres commented Aug 14, 2023

Copy link
Copy Markdown
Contributor

If a persistent shared class cache is started under certain conditions (in a container, readonly, JITServer AOT cache enabled, JIT and AOT compilations enabled), the SCC startup will now ignore the readonly flag and instead initialize a temporary new (writable) top layer for the JITServer AOT relocation mechanism to use.

New options -XX:+JITServerAOTCacheUseTemporaryLayer and -XX:+JITServerAOTCacheUseTemporaryLayer control this mechanism; adding the positive option will cause the layer to be created even if we are not running in a container or readonly (useful for testing purposes) but not in more scenarios than that, and adding the negative option will disable the feature completely.

When using the JITServer AOT cache, it is now the default not to store received method bodies in the local shared class cache. Setting the environment variable TR_enableRemoteAOTMethodStorage will restore the old behaviour. Due to these changes, the TR_disableRemoteAOTMethodStorage environment variable, which formerly disabled the storage of remote AOT bodies in the local SCC, is redundant and is no longer recognized.

Signed-off-by: Christian Despres despresc@ibm.com

@cjjdespres

Copy link
Copy Markdown
Contributor Author

Attn @mpirvu. Line ending stripping on CompositeCache.cpp has created a large diff.

I still need to add in the rest of the rest of the restrictions on the layer creation (e.g., when -Xaot:none is specified) and disable method body storage in the new layer. That will not be difficult.

@mpirvu mpirvu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few minor suggestions

Comment thread runtime/compiler/control/HookedByTheJit.cpp Outdated
Comment thread runtime/shared/shrclssup.c Outdated
Comment thread runtime/oti/j9nonbuilder.h Outdated
@mpirvu mpirvu self-assigned this Aug 14, 2023
@mpirvu mpirvu added comp:jitserver Artifacts related to JIT-as-a-Service project comp:vm labels Aug 14, 2023
@mpirvu

mpirvu commented Aug 14, 2023

Copy link
Copy Markdown
Contributor

Another issue we discussed: the new non-persistent layer should be added only if -Xnoaot or -Xint are not in effect. Basically we want AOT to be enabled.

Comment thread runtime/shared/shrclssup.c Outdated
Comment thread runtime/shared_common/OSCachemmap.cpp Outdated
@mpirvu

mpirvu commented Aug 18, 2023

Copy link
Copy Markdown
Contributor

I would like this feature to become the default under the conditions specified (JITServer enabled, JITServer AOT cache enabled, running in containers, SCC is readonly), but we also need an option to disable it in case there is something wrong with it. We will have to document the change in behavior and the new option.

@cjjdespres
cjjdespres force-pushed the late-layer-with-options-hack branch from 412aa1d to 61ca0aa Compare August 21, 2023 14:51
@cjjdespres

Copy link
Copy Markdown
Contributor Author

I believe those are all the @mpirvu suggestions dealt with. The shouldEnableJITServerAOTCacheLayer function has the exact conditions under which the layer activates. Since some things have been changed a little bit, I still want to re-test this with the benchmarks, but you can take a look again.

I haven't disabled storage of locally-compiled AOT method bodies in the temporary layer - should I do that?

@mpirvu

mpirvu commented Aug 21, 2023

Copy link
Copy Markdown
Contributor

I haven't disabled storage of locally-compiled AOT method bodies in the temporary layer - should I do that?

Yes. I would like the extra layer to be as small as possible and to be used as little as possible.

@cjjdespres

Copy link
Copy Markdown
Contributor Author

Now that I think about it, we haven't yet tested relocating local compilations without storing them in the local SCC first. We've only done that for remote AOT methods. There shouldn't be a problem, but that might need to be tested too.

Otherwise, maybe we could forbid fresh local AOT compilations? Is there a good way of doing that?

@mpirvu

mpirvu commented Aug 21, 2023

Copy link
Copy Markdown
Contributor

All AOT compilations are sent to the server as far as I know (as long as there is a server connection).
Therefore, we can store local AOT compilations into the local SCC, because we don't expect any in normal operation.

@cjjdespres

Copy link
Copy Markdown
Contributor Author

Okay, so nothing needs to be done, then, unless we're particularly concerned about the case where a client loses connection with the server for a long time.

Comment thread runtime/shared/shrclssup.c Outdated
@cjjdespres
cjjdespres force-pushed the late-layer-with-options-hack branch from 61ca0aa to 1e7f2f1 Compare August 21, 2023 17:41
@cjjdespres
cjjdespres marked this pull request as ready for review August 21, 2023 19:02
@cjjdespres
cjjdespres force-pushed the late-layer-with-options-hack branch from 1e7f2f1 to e92dd33 Compare August 22, 2023 14:24

@mpirvu mpirvu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mpirvu

mpirvu commented Aug 22, 2023

Copy link
Copy Markdown
Contributor

@hangshao0 ready for your final review
FYI @pshipton in case you want to review it as well. Thanks

Comment thread runtime/shared/shrclssup.c Outdated
Comment thread runtime/shared_common/OSCachemmap.cpp Outdated
@hangshao0

Copy link
Copy Markdown
Contributor

Don't forget to create the documentation issue and link this change to it.

@cjjdespres
cjjdespres force-pushed the late-layer-with-options-hack branch from e92dd33 to c8dbdab Compare August 22, 2023 16:48
@cjjdespres

Copy link
Copy Markdown
Contributor Author

Regarding the documentation - although we ignore the readonly flag, we do still create a new (temporary) top layer, which should have the effect of making the old top layer read-only. Is there any user-facing difference in behaviour between -Xshareclasses:readonly and the lower-layer read-only status that needs to be pointed out? Otherwise we could mention this in the JITServer AOT cache documentation, or not at all.

@cjjdespres

Copy link
Copy Markdown
Contributor Author

That should be all the reviewer comments addressed, as well.

@hangshao0

Copy link
Copy Markdown
Contributor

Regarding the documentation - although we ignore the readonly flag, we do still create a new (temporary) top layer, which should have the effect of making the old top layer read-only. Is there any user-facing difference in behaviour between -Xshareclasses:readonly and the lower-layer read-only status that needs to be pointed out? Otherwise we could mention this in the JITServer AOT cache documentation, or not at all.

User may not feel the noticeable difference on lower-layer read-only status, but I think it is better to be transparent to the users on what is expected to happen on their system in this new mode. (e.g. a new temporary layer will be created and deleted). If we plan to put more detailed documentation in the JITServer AOT cache section/pages, we can add a link to it in -Xshareclasses:readonly documentation.

Comment thread runtime/shared_common/j9shr.tdf Outdated
@mpirvu

mpirvu commented Aug 23, 2023

Copy link
Copy Markdown
Contributor

jenkins compile all jdk17

@mpirvu

mpirvu commented Aug 23, 2023

Copy link
Copy Markdown
Contributor

jenkins test sanity zlinux,zlinuxjit jdk17

@mpirvu

mpirvu commented Aug 23, 2023

Copy link
Copy Markdown
Contributor

zlinux testing failed due to infra:

12:17:36  Exception: hudson.AbortException: Failed to copy artifacts from Test_openjdk17_j9_sanity.functional_s390x_linux_Personal_testList_0 with filter: **/*.tap

@mpirvu

mpirvu commented Aug 23, 2023

Copy link
Copy Markdown
Contributor

jenkins test sanity zlinux jdk17

@mpirvu

mpirvu commented Aug 23, 2023

Copy link
Copy Markdown
Contributor

jenkins test sanity plinuxjit jdk17

@mpirvu

mpirvu commented Aug 24, 2023

Copy link
Copy Markdown
Contributor

jenkins test sanity xlinuxjit jdk17

@mpirvu

mpirvu commented Aug 24, 2023

Copy link
Copy Markdown
Contributor

On plinuxjit we have two failures:

cmdLineTester_jvmtitests_1
variation: Mode148
JVM_OPTIONS: -XX:+UseJITServer -Xjit -Xgcpolicy:gencon -Xshareclasses:name=bcienabled,enableBCI -Xnocompressedrefs 
Testing: emex001
Test start time: 2023/08/23 20:42:50 Coordinated Universal Time
Running command: "/home/jenkins/workspace/Test_openjdk17_j9_sanity.functional_ppc64le_linux_jit_Personal_testList_0/openjdkbinary/j2sdk-image/bin/java" -XX:+UseJITServer -Xjit -Xgcpolicy:gencon -Xshareclasses:name=bcienabled,enableBCI -Xnocompressedrefs  -Xdump    -agentlib:jvmtitest=test:emex001 -cp "/home/jenkins/workspace/Test_openjdk17_j9_sanity.functional_ppc64le_linux_jit_Personal_testList_0/aqa-tests/TKG/../../jvmtest/functional/cmdLineTests/jvmtitests/jvmtitest.jar" com.ibm.jvmti.tests.util.TestRunner
Time spent starting: 5 milliseconds
Time spent executing: 22781 milliseconds
Test result: FAILED
Output from test:
 [ERR] Unhandled exception
 [ERR] Type=Segmentation error vmState=0x00000000
...
 [ERR] ----------- Stack Backtrace -----------
 [ERR] jvmtiHookMethodExit+0x280 (0x00007FFFB97A5A30 [libj9jvmti29.so+0x25a30])
 [ERR] J9HookDispatch+0x1e0 (0x00007FFFBB3C1960 [libj9hookable29.so+0x1960])
 [ERR] old_slow_jitReportMethodExit+0x18c (0x00007FFFBA9D352C [libj9jit29.so+0xc4352c])
 [ERR]  (0x00007FFFBA9E7F50 [libj9jit29.so+0xc57f50])
 [ERR] sendResolveInvokeDynamic+0x26c (0x00007FFFBB519B6C [libj9vm29.so+0x19b6c])
 [ERR] resolveInvokeDynamic+0x240 (0x00007FFFBB58F0B0 [libj9vm29.so+0x8f0b0])
 [ERR] debugBytecodeLoopFull+0x34260 (0x00007FFFBB66DCF0 [libj9vm29.so+0x16dcf0])
 [ERR]  (0x00007FFFBB66F980 [libj9vm29.so+0x16f980])
 [ERR] runCallInMethod+0x258 (0x00007FFFBB519F18 [libj9vm29.so+0x19f18])
 [ERR] gpProtectedRunCallInMethod+0x54 (0x00007FFFBB543DC4 [libj9vm29.so+0x43dc4])
 [ERR] signalProtectAndRunGlue+0x28 (0x00007FFFBB683628 [libj9vm29.so+0x183628])
 [ERR] omrsig_protect+0x3f4 (0x00007FFFBB469F74 [libj9prt29.so+0x39f74])
 [ERR] gpProtectAndRun+0xa8 (0x00007FFFBB6836F8 [libj9vm29.so+0x1836f8])
 [ERR] gpCheckCallin+0xc4 (0x00007FFFBB546484 [libj9vm29.so+0x46484])
 [ERR] callStaticVoidMethod+0x48 (0x00007FFFBB5433C8 [libj9vm29.so+0x433c8])
 [ERR] JavaMain+0x11e4 (0x00007FFFBBF375C4 [libjli.so+0x75c4])

and

testJITServer_1
variation: Mode610 -Xshareclasses:none -Xjit:optLevel=hot
JVM_OPTIONS: -XX:+UseJITServer -Xcompressedrefs -Xjit -Xgcpolicy:gencon -Xshareclasses:none -Xjit:optLevel=hot 
...
Expected an exit value of 0 or 143, got 1 instead.
Dumping the contents of log file: /home/jenkins/workspace/Test_openjdk17_j9_sanity.functional_ppc64le_linux_jit_Personal_testList_0/aqa-tests/TKG/output_16928206762116/testJITServer_1/testServer.client.out
////////////////////////////////////////////////////////////////////////
//// JVMDUMP039I Processing dump event "abort", detail "" at 2023/08/23 21:39:10 - please wait.
//// JVMDUMP032I JVM requested System dump using '/home/jenkins/workspace/Test_openjdk17_j9_sanity.functional_ppc64le_linux_jit_Personal_testList_0/aqa-tests/TKG/output_16928206762116/testJITServer_1/core.20230823.213910.3846244.0001.dmp' in response to an event

On zlinuxjit we had one failure:

testJITServer_1
variation: Mode610 -Xshareclasses:none -Xjit:optLevel=hot
JVM_OPTIONS: -XX:+UseJITServer -Xcompressedrefs -Xjit -Xgcpolicy:gencon -Xshareclasses:none -Xjit:optLevel=hot 
...
Expected an exit value of 0 or 143, got 1 instead.
Dumping the contents of log file: /home/jenkins/workspace/Test_openjdk17_j9_sanity.functional_s390x_linux_jit_Personal_testList_1/aqa-tests/TKG/output_16927994224975/testJITServer_1/testServer.client.out
////////////////////////////////////////////////////////////////////////
//// JVMDUMP039I Processing dump event "abort", detail "" at 2023/08/23 10:25:43 - please wait.
//// JVMDUMP032I JVM requested System dump using '/home/jenkins/workspace/Test_openjdk17_j9_sanity.functional_s390x_linux_jit_Personal_testList_1/aqa-tests/TKG/output_16927994224975/testJITServer_1/core.20230823.102543.8942.0001.dmp' in response to an event
...

On zLinux we had one failure

testJITServer_1
variation: Mode610 -Xshareclasses:none -Xjit:optLevel=hot
JVM_OPTIONS:  -Xcompressedrefs -Xjit -Xgcpolicy:gencon -Xshareclasses:none -Xjit:optLevel=hot 
...
Expected an exit value of 0 or 143, got 1 instead.
Dumping the contents of log file: /home/jenkins/workspace/Test_openjdk17_j9_sanity.functional_s390x_linux_Personal_testList_1/aqa-tests/TKG/output_16928138457222/testJITServer_1/testServer.client.out
////////////////////////////////////////////////////////////////////////
//// JVMDUMP039I Processing dump event "abort", detail "" at 2023/08/23 14:16:25 - please wait.
//// JVMDUMP032I JVM requested System dump using '/home/jenkins/workspace/Test_openjdk17_j9_sanity.functional_s390x_linux_Personal_testList_1/aqa-tests/TKG/output_16928138457222/testJITServer_1/core.20230823.141625.21320.0001.dmp' in response to an event
...

While I don't think that this PR caused these issues, we do seem to have a problem with JITServer

@mpirvu

mpirvu commented Aug 24, 2023

Copy link
Copy Markdown
Contributor

jenkins test sanity xlinux,plinux jdk17

@pshipton

Copy link
Copy Markdown
Member

The emex001 failure is #17889

@cjjdespres

cjjdespres commented Aug 24, 2023

Copy link
Copy Markdown
Contributor Author

The 100x grinder https://hyc-runtimes-jenkins.swg-devops.com/job/Grinder/34446/ of testJITServer_1 on Z does not appear to show any issues with master.

@cjjdespres

Copy link
Copy Markdown
Contributor Author

It's possible that with -Xshareclasses:none the vm->sharedCacheAPI->usingJITServerAOTCacheLayer query in samplerThreadProc is failing. There's a javacoreData->usingJITServerAOTCacheLayer field now, so it's probably better to use that anyway.

@cjjdespres
cjjdespres force-pushed the late-layer-with-options-hack branch from 4cd1fb2 to f22d6f7 Compare August 24, 2023 13:26
@cjjdespres

Copy link
Copy Markdown
Contributor Author

Pushed to add that change. I also removed the #if defined(J9VM_OPT_JITSERVER) bit around the log message for uniformity because none of the other changes are guarded by it. I can instead add that back and put it around more of the changes if that's desired.

@mpirvu

mpirvu commented Aug 24, 2023

Copy link
Copy Markdown
Contributor

Now that I think about it, it was indeed the line that was accessing vm->sharedCacheAPI in samplerThreadProc() on the path where we don't guarantee the existence of the SCC.

I looked at runtime/rasdump/javadump.cpp and it uses #if defined(J9VM_OPT_JITSERVER) for parts that are related to JITServer. I think we should protect the new code as well for uniformity.

If a persistent shared class cache is started under certain conditions
(in a container, readonly, JITServer AOT cache enabled, JIT and AOT
compilations enabled), the SCC startup will now ignore the readonly flag
and instead initialize a temporary new (writable) top layer for the
JITServer AOT relocation mechanism to use.

New options -XX:+JITServerAOTCacheUseTemporaryLayer and
-XX:+JITServerAOTCacheUseTemporaryLayer control this mechanism; adding
the positive option will cause the layer to be created even if we are
not running in a container or readonly (useful for testing purposes) but
not in more scenarios than that, and adding the negative option will
disable the feature completely.

When using the JITServer AOT cache, it is now the default not to store
received method bodies in the local shared class cache. Setting the
environment variable TR_enableRemoteAOTMethodStorage will restore the
old behaviour. Due to these changes, the
TR_disableRemoteAOTMethodStorage environment variable, which
formerly disabled the storage of remote AOT bodies in the local SCC, is
redundant and is no longer recognized.

Signed-off-by: Christian Despres <despresc@ibm.com>
@cjjdespres
cjjdespres force-pushed the late-layer-with-options-hack branch from f22d6f7 to 080f6c6 Compare August 24, 2023 15:48
@cjjdespres

Copy link
Copy Markdown
Contributor Author

That should be all the code guarded, now.

@mpirvu

mpirvu commented Aug 24, 2023

Copy link
Copy Markdown
Contributor

jenkins compile all jdk17

@mpirvu

mpirvu commented Aug 24, 2023

Copy link
Copy Markdown
Contributor

jenkins test sanity zlinux,zlinuxjit jdk17

@mpirvu
mpirvu merged commit 6f21b13 into eclipse-openj9:master Aug 25, 2023
Comment on lines +3005 to +3006
TraceEvent=Trc_SHR_OSC_Mmap_startup_jitserverlayergooddelete NoEnv Overhead=1 Level=1 Template="SH_OSCachemmap::startup: deleteCacheFile succeeded for cache path name = %s, file handle %d"
TraceException=Trc_SHR_OSC_Mmap_startup_jitserverlayerbaddelete NoEnv Overhead=1 Level=1 Template="SH_OSCachemmap::startup: deleteCacheFile failed for cache path name = %s, file handle %d"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The final parameter of each of these messages should be %zd (not %d) because the argument type is IDATA.

@mpirvu

mpirvu commented Aug 25, 2023

Copy link
Copy Markdown
Contributor

@cjjdespres Could you please open another PR to address the issue mentioned by @keithc-ca ? Thanks

const std::string &codeCacheStr, const std::string &dataCacheStr)
{
static const bool shouldStoreRemoteAOTMethods = !feGetEnv("TR_disableRemoteAOTMethodStorage");
static const bool shouldStoreRemoteAOTMethods = feGetEnv("TR_enableRemoteAOTMethodStorage");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI it looks like this breaks the -XX:+JITServerAOTCacheDelayMethodRelocation option added in #17509. Since methods received from the server AOT cache are no longer stored in the local SCC (by default), after we try to delay the load by replenishing the invocation count, the next time the method reaches count 0 and is queued for compilation, there is no AOT body in the local SCC, resulting in a new remote compilation request. If it gets served from the server AOT cache again, this could even lead to an infinite loop and the method would stay interpreted.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should probably allow storage if that option is enabled. Either that, or ignore the option if we really don't want to store any methods in the local SCC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:doc comp:jitserver Artifacts related to JIT-as-a-Service project comp:vm

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants