openj9 icon indicating copy to clipboard operation
openj9 copied to clipboard

[WIP] Virtual thread support for JVMTI extension functions.

Open thallium opened this issue 1 year ago • 1 comments

thallium avatar Jan 30 '24 19:01 thallium

@babsingh FYI

thallium avatar Jan 30 '24 19:01 thallium

@thallium This is becoming a large PR (1000+ lines). Please create a separate PR for each JVMTI extension function for ease of reviewing and reducing the risk of failures.

When do you expect to finish this work?

Related: #18386

fyi @pshipton @TobiAjila

babsingh avatar Feb 23 '24 22:02 babsingh

@babsingh Currently I'm investigating the intermittent test failure of added tests so I should be able to finalize the PR next week.

Actually a lot of the changes are formatting changes and the test code for GetStackTraceExtended and GetThreadListStackTracesExtended are pretty much the same so the actual code to be reviewed is much less.

thallium avatar Feb 24 '24 01:02 thallium

@babsingh The PR is ready for review. Can you please take a look?

thallium avatar Mar 04 '24 16:03 thallium

5x60 tests passed https://hyc-runtimes-jenkins.swg-devops.com/view/Test_grinder/job/Grinder/38282/

thallium avatar Mar 06 '24 01:03 thallium

PR title shouldn't have a full-stop; I have removed it.

The PR description and commit message needs more details:

  • which JVMTI extension functions are updated?
  • what do the tests do?
  • link to the related issue: https://github.com/eclipse-openj9/openj9/issues/18386.

The tests should also have a comment with a high-level description.

babsingh avatar Mar 06 '24 17:03 babsingh

@llxia Requesting your review for the test changes.

babsingh avatar Mar 06 '24 17:03 babsingh

There are typos in the commit messages. Correction version:

In each of the tests, a virtual thread runs methodToCompile()
for a relatively large number of iterations to JIT compile the
method. Then, we use the JVMTI Extension API to check if there
are any JITted frames in the stack trace of the virtual thread.
We test this for both mounted and unmounted virtual threads.

babsingh avatar Mar 07 '24 23:03 babsingh

@llxia There are two variants of existing tests in jvmtitests/playlist.xml: ^arch.390 and arch.390. Do we need to do the same for the new test?

babsingh avatar Mar 07 '24 23:03 babsingh

The new test cmdLineTester_jvmtitests_Java21andUp only uses jvmtitests_Java21andUp.xml that you added. Do we want it to run on arch.390?

llxia avatar Mar 08 '24 14:03 llxia

The new test cmdLineTester_jvmtitests_Java21andUp only uses jvmtitests_Java21andUp.xml that you added. Do we want it to run on arch.390?

It should be run everywhere. But, existing tests have two targets: one for arch.390 (e.g. cmdLineTester_jvmtitests_nongold) and another for non arch.390 platforms (e.g cmdLineTester_jvmtitests). The only visible difference is that the arch.390 test target is tagged to extended.functional whereas the non arch.390 test target is tagged to sanity.functional. Not sure why this was done. If it doesn't matter anymore, we can just have one test target.

babsingh avatar Mar 08 '24 14:03 babsingh

I've updated the test variations to test different GC policies. Do we need to test compressed ref as well?

thallium avatar Mar 08 '24 21:03 thallium

Do we need to test compressed ref as well?

The current settings have compressed refs enabled.

These changes LGTM. I plan to launch the PR builds. @llxia Do the test changes look good to you?

babsingh avatar Mar 11 '24 14:03 babsingh

jenkins test sanity.functional,extended.functional zlinux jdk11

babsingh avatar Mar 12 '24 01:03 babsingh

jenkins test sanity.functional,extended.functional,sanity.openjdk,extended.openjdk win,alinux jdk21

babsingh avatar Mar 12 '24 01:03 babsingh

jenkins test extended.functional,sanity.openjdk,extended.openjdk amac jdk22

babsingh avatar Mar 12 '24 01:03 babsingh

PR build errors (test code shouldn't be compiled on JDK11):

05:51:28      [javac] /home/jenkins/workspace/Test_openjdk11_j9_extended.functional_s390x_linux_Personal_testList_0/aqa-tests/functional/cmdLineTests/jvmtitests/src/com/ibm/jvmti/tests/getStackTraceExtended/gste002.java:78: error: cannot find symbol
05:51:28      [javac] 			Thread t1 = Thread.ofVirtual().name("vthread 1").start(() -> {
05:51:28      [javac] 			                  ^
05:51:28      [javac]   symbol:   method ofVirtual()
05:51:28      [javac]   location: class Thread
05:51:28      [javac] /home/jenkins/workspace/Test_openjdk11_j9_extended.functional_s390x_linux_Personal_testList_0/aqa-tests/functional/cmdLineTests/jvmtitests/src/com/ibm/jvmti/tests/getStackTraceExtended/gste002.java:116: error: cannot find symbol
05:51:28      [javac] 		try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
05:51:28      [javac] 		                             ^
05:51:28      [javac]   symbol:   method newVirtualThreadPerTaskExecutor()
05:51:28      [javac]   location: class Executors
05:51:28      [javac] /home/jenkins/workspace/Test_openjdk11_j9_extended.functional_s390x_linux_Personal_testList_0/aqa-tests/functional/cmdLineTests/jvmtitests/src/com/ibm/jvmti/tests/getThreadListStackTracesExtended/gtlste002.java:78: error: cannot find symbol
05:51:28      [javac] 			Thread t1 = Thread.ofVirtual().name("vthread 1").start(() -> {
05:51:28      [javac] 			                  ^
05:51:28      [javac]   symbol:   method ofVirtual()
05:51:28      [javac]   location: class Thread
05:51:28      [javac] /home/jenkins/workspace/Test_openjdk11_j9_extended.functional_s390x_linux_Personal_testList_0/aqa-tests/functional/cmdLineTests/jvmtitests/src/com/ibm/jvmti/tests/getThreadListStackTracesExtended/gtlste002.java:116: error: cannot find symbol
05:51:28      [javac] 		try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {

babsingh avatar Mar 12 '24 19:03 babsingh

test code shouldn't be compiled on JDK11

@llxia Could you help with this issue? Which part need to be modified?

thallium avatar Mar 13 '24 15:03 thallium

See existing tests such as soae001 (Java11andUp). One missing item in runtime/tests/jvmtitests/agent/tests.c is

#if JAVA_SPEC_VERSION >= 21
   { "gste002", gste002, "com.ibm.jvmti.tests.getStackTraceExtended.gste002", "GetStackTraceExtended" },
   { "gtlste002", gtlste002, "com.ibm.jvmti.tests.getThreadListStackTracesExtended.gtlste002", "GetThreadListStackTracesExtended" },
#endif /* JAVA_SPEC_VERSION >= 21 */

babsingh avatar Mar 13 '24 15:03 babsingh

@babsingh all the above changes are mostly related to the native functions. We haven't add anything to prevent the Java testing code from compiling. In the playlist.xml we already have:

		<versions>
			<version>21+</version>
		</versions>

but that doesn't seem to be effective. I'm stilling getting the same error in my local testing.

thallium avatar Mar 13 '24 19:03 thallium

In .../jvmtitests/build.xml, adding <exclude name="... for those files might prevent them from compiling. @llxia for confirming?

babsingh avatar Mar 13 '24 21:03 babsingh

playlist.xml controls the execution only. For java compilation, we need to update build.xml.

<if>
<not>
   <equals arg1="${JDK_VERSION}" arg2="11" />
</not>
    //add additional exclude files
       ...

https://github.com/eclipse-openj9/openj9/blob/6b03a382a12a2293d1cb4d884c55899859da516e/test/functional/cmdLineTests/jvmtitests/build.xml#L81

llxia avatar Mar 16 '24 12:03 llxia

I've added exclude files to build.xml.

thallium avatar Mar 17 '24 16:03 thallium

jenkins test extended.functional zlinux jdk11

babsingh avatar Mar 18 '24 15:03 babsingh

jenkins test extended.functional,extended.openjdk win,alinux jdk21

babsingh avatar Mar 18 '24 15:03 babsingh

jenkins test extended.functional,extended.openjdk amac jdk22

babsingh avatar Mar 18 '24 15:03 babsingh

LGTM. @llxia I will merge the PR after you complete your review.

https://openj9-jenkins.osuosl.org/job/Test_openjdk21_j9_extended.openjdk_x86-64_windows_Personal/3

An infra issue similar to https://github.com/eclipse-openj9/openj9/issues/8446 is seen in the above PR build, which is unrelated to this PR. fyi @AdamBrousseau

babsingh avatar Mar 19 '24 13:03 babsingh