Skip to content

Conversation

@sendaoYan
Copy link
Member

@sendaoYan sendaoYan commented Feb 11, 2025

H all,

This PR add /native keyword in the test header for virtual thread tests. The /native keyword will make run the related tests by jtreg standalone more friendly.

I runed all the tests without -nativepath argument and find the fail tests. This will find all the virtual thread tests which missing '/native' flag.

  1. java/lang/management/ThreadMXBean/VirtualThreads.java#default

VirtualThreads.java:223 call "invoker()" in test/lib/jdk/test/lib/thread/VThreadPinner.java file, which will call the native function "call".
java/lang/management/ThreadMXBean/VirtualThreads.java#no-vmcontinuations run this test with VM option "-XX:-VMContinuations" and assumeTrue(VThreadScheduler.supportsCustomScheduler(), "No support for custom schedulers"); will make junit skip the 'testGetThreadInfoCarrierThread' unit test, so 'VirtualThreads.java#no-vmcontinuations' do not need '/native' keywork.

  1. java/lang/Thread/virtual/stress/PinALot.java

PinALot.java:58 call "invoker()" in test/lib/jdk/test/lib/thread/VThreadPinner.java file, which will call the native function "call".

  1. java/lang/Thread/virtual/SynchronizedNative.java

Call System.loadLibrary("SynchronizedNative") at line 85.

  1. Tests java/lang/Thread/virtual/stress/GetStackTraceALotWhenPinned.java, java/lang/Thread/virtual/ThreadAPI.java, java/lang/Thread/virtual/RetryMonitorEnterWhenPinned.java, java/lang/Thread/virtual/MonitorWaitNotify.java, java/lang/Thread/virtual/MonitorPinnedEvents.java, java/lang/Thread/virtual/MonitorEnterExit.java and other tests are similar to java/lang/Thread/virtual/stress/PinALot.java
  • Why we need the '/native' keywork?

I usually run the tests through jtreg directively, rather than run the tests through make test. If I run the test which load the native shared library files and the test missing '/native' keyword but I forgot to pass the '-nativepath' argument to jtreg, or pass the incorrect '-nativepath' argument to jtreg, sometimes it will report timeouted after a long time, such as java/lang/Thread/virtual/JfrEvents.java. If we add the missing '/native' keywork, jtreg will report 'Error. Use -nativepath to specify the location of native code' right away. So add the missing '/native' keyword will make run the tests more friendly.

Change has been verified locally, test-fix, no risk.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8349689: Several virtual thread tests missing /native keyword (Sub-task - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/23550/head:pull/23550
$ git checkout pull/23550

Update a local copy of the PR:
$ git checkout pull/23550
$ git pull https://git.openjdk.org/jdk.git pull/23550/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 23550

View PR using the GUI difftool:
$ git pr show -t 23550

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/23550.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 11, 2025

👋 Welcome back syan! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Feb 11, 2025

@sendaoYan This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8349689: Several virtual thread tests missing /native keyword

Reviewed-by: alanb, lmesnik

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 23 new commits pushed to the master branch:

  • 8c09d40: 8348268: Test gc/shenandoah/TestResizeTLAB.java#compact: fatal error: Before Updating References: Thread C2 CompilerThread1: expected gc-state 9, actual 21
  • e7157d1: 8150442: Enforce Supported Platforms in Packager for MSI bundles
  • 6428165: 8349254: Disable "best-fit" mapping on Windows environment variables
  • 32dc41c: 8349624: Validation for slot missing in CodeBuilder local variable instructions
  • a1bcda2: 8349579: jsvml.dll incorrect RDATA SEGMENT specification
  • ee079fd: 8349820: Temporarily increase MemLimit for tests until JDK-8349772 and JDK-8337821 are fixed
  • 545d19f: 8349771: Replace usages of -mx and -ms in some monitor tests
  • 5ee44c1: 8349662: SSLTube SSLSubscriptionWrapper has potential races when switching subscriptions
  • 964dd18: 8349515: [REDO] Framework for tracing makefile inclusion and parsing
  • 8e85829: 8349213: G1: Clearing bitmaps during collection set merging not claimed by region
  • ... and 13 more: https://git.openjdk.org/jdk/compare/8f6ccde9829ea0e4fe1c087e68bec4d9efb55c64...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 11, 2025
@openjdk
Copy link

openjdk bot commented Feb 11, 2025

@sendaoYan The following labels will be automatically applied to this pull request:

  • core-libs
  • nio
  • serviceability

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org nio nio-dev@openjdk.org core-libs core-libs-dev@openjdk.org labels Feb 11, 2025
@mlbridge
Copy link

mlbridge bot commented Feb 11, 2025

Webrevs

@AlanBateman
Copy link
Contributor

Can you check if these two needs to be updated too?

test/jdk/java/lang/Thread/virtual/ThreadPollOnYield.java
test/jdk/java/lang/Thread/virtual/Starvation.java

sendaoYan added 2 commits February 11, 2025 15:39
…ent/ThreadMXBean/VirtualThreads.java#default
…ava test/jdk/java/lang/Thread/virtual/Starvation.java
@sendaoYan
Copy link
Member Author

sendaoYan commented Feb 11, 2025

Can you check if these two needs to be updated too?

test/jdk/java/lang/Thread/virtual/ThreadPollOnYield.java test/jdk/java/lang/Thread/virtual/Starvation.java

These two tests also need /native keyword.

  • Test test/jdk/java/lang/Thread/virtual/ThreadPollOnYield.java do not report test failed or error when missing load the native shared libary. So I add a check to make sure that the first virtual of this test run normally.

The original test output from jfr file shows below:

STARTED    ThreadPollOnYield::testThreadYieldPolls 'testThreadYieldPolls()'
Exception in thread "" java.lang.ExceptionInInitializerError
    at ThreadPollOnYield.lambda$testThreadYieldPolls$0(ThreadPollOnYield.java:59)
    at java.base/java.lang.VirtualThread.run(VirtualThread.java:466)
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Cannot open library: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib/libVThreadPinner.so
    at jdk.test.lib.thread.VThreadPinner.invoker(VThreadPinner.java:135)
    at jdk.test.lib.thread.VThreadPinner.<clinit>(VThreadPinner.java:50)
    ... 2 more
Caused by: java.lang.IllegalArgumentException: Cannot open library: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib/libVThreadPinner.so
    at java.base/java.lang.foreign.SymbolLookup.libraryLookup(SymbolLookup.java:350)
    at java.base/java.lang.foreign.SymbolLookup.libraryLookup(SymbolLookup.java:335)
    at jdk.test.lib.thread.VThreadPinner.invoker(VThreadPinner.java:130)
    ... 3 more
Exception in thread "" java.lang.NoClassDefFoundError: Could not initialize class jdk.test.lib.thread.VThreadPinner
    at ThreadPollOnYield.lambda$testThreadYieldPolls$2(ThreadPollOnYield.java:69)
    at java.base/java.lang.VirtualThread.run(VirtualThread.java:466)
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.RuntimeException: java.lang.IllegalArgumentException: Cannot open library: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib/libVThreadPinner.so [in thread "ForkJoinPool-1-worker-1"]
    at jdk.test.lib.thread.VThreadPinner.invoker(VThreadPinner.java:135)
    at jdk.test.lib.thread.VThreadPinner.<clinit>(VThreadPinner.java:50)
    at ThreadPollOnYield.lambda$testThreadYieldPolls$0(ThreadPollOnYield.java:59)
    ... 1 more
SUCCESSFUL ThreadPollOnYield::testThreadYieldPolls 'testThreadYieldPolls()'
  • Test test/jdk/java/lang/Thread/virtual/Starvation.java execute over 120 seconds on my local environment. So I add timeout=200 also.
elapsed time (seconds): 121.41

sendaoYan added 2 commits February 11, 2025 16:49
…VirtualThreads.java; Split @run line for test/jdk/java/lang/Thread/virtual/ThreadPollOnYield.java
Copy link
Contributor

@AlanBateman AlanBateman left a comment

Choose a reason for hiding this comment

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

912c1ab looks okay.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Feb 11, 2025
@sendaoYan
Copy link
Member Author

912c1ab looks okay.

@AlanBateman Thanks for the patience suggest and review.

@sendaoYan
Copy link
Member Author

Thanks all for the reviews.

/integrate

@openjdk
Copy link

openjdk bot commented Feb 12, 2025

Going to push as commit 88b4a90.
Since your change was applied there have been 24 commits pushed to the master branch:

  • d558d9d: 8349702: jdk.internal.net.http.Http2Connection::putStream needs to provide cause while cancelling stream
  • 8c09d40: 8348268: Test gc/shenandoah/TestResizeTLAB.java#compact: fatal error: Before Updating References: Thread C2 CompilerThread1: expected gc-state 9, actual 21
  • e7157d1: 8150442: Enforce Supported Platforms in Packager for MSI bundles
  • 6428165: 8349254: Disable "best-fit" mapping on Windows environment variables
  • 32dc41c: 8349624: Validation for slot missing in CodeBuilder local variable instructions
  • a1bcda2: 8349579: jsvml.dll incorrect RDATA SEGMENT specification
  • ee079fd: 8349820: Temporarily increase MemLimit for tests until JDK-8349772 and JDK-8337821 are fixed
  • 545d19f: 8349771: Replace usages of -mx and -ms in some monitor tests
  • 5ee44c1: 8349662: SSLTube SSLSubscriptionWrapper has potential races when switching subscriptions
  • 964dd18: 8349515: [REDO] Framework for tracing makefile inclusion and parsing
  • ... and 14 more: https://git.openjdk.org/jdk/compare/8f6ccde9829ea0e4fe1c087e68bec4d9efb55c64...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Feb 12, 2025
@openjdk openjdk bot closed this Feb 12, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Feb 12, 2025
@openjdk
Copy link

openjdk bot commented Feb 12, 2025

@sendaoYan Pushed as commit 88b4a90.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2025 Oracle and/or its affiliates. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

You missed the comma after 2025 here. This is now causing failures in our CI.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I create a new issue JDK-8349876 for that.

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

Labels

core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated nio nio-dev@openjdk.org serviceability serviceability-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

5 participants