Details
-
Bug
-
Resolution: Fixed
-
P4
-
17, 21
-
b23
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8312202 | 17.0.9-oracle | Calvin Cheung | P4 | Resolved | Fixed | b03 |
JDK-8312540 | 17.0.9 | Goetz Lindenmaier | P4 | Resolved | Fixed | b01 |
Description
I could reproduce the issue locally with a simple test case - see attached UnparkRegression.java
It creates 10K idle threads that sleep indefinitely and two active threads communicating to each other via CyclicBarrier. The particular synchronization primitive does not matter: any java.util.concurrent class that eventually calls LockSupport.unpark is affected by the issue.
Running the test with JDK 17 or JDK 20 on 4-core ARM64 machine, it does 70K roundtrips per second, while with JDK 8 it does 162K (2.3x more).
The issue appeared in JDK 10 with the introduction of Thread-SMR. The problem is the linear search in ThreadsList::includes called by cv_internal_thread_to_JavaThread:
https://github.com/openjdk/jdk/blob/44f33ad1a9617fc23864c9ba5f063b3fc2f1e18c/src/hotspot/share/runtime/threadSMR.cpp#L829
The call to ThreadList::includes is guarded by a diagnostic flag `EnableThreadSMRExtraValidityChecks` which is enabled by default.
After adding -XX:-EnableThreadSMRExtraValidityChecks, the performance returns back to JDK 8 levels.
Attachments
Issue Links
- backported by
-
JDK-8312202 Performance regression in LockSupport.unpark with lots of idle threads
- Resolved
-
JDK-8312540 Performance regression in LockSupport.unpark with lots of idle threads
- Resolved
- is blocked by
-
JDK-8307068 store a JavaThread* in the java.lang.Thread object after the JavaThread* is added to the main ThreadsList
- Resolved
- relates to
-
JDK-8307970 Thread.start is slow with large number of threads
- Open
-
JDK-8167108 inconsistent handling of SR_lock can lead to crashes
- Resolved
-
JDK-8307483 New micros for j.u.c.LockSupport
- Resolved
- links to
-
Commit openjdk/jdk17u-dev/504ec276
-
Commit openjdk/jdk/f030937a
-
Review openjdk/jdk17u-dev/1604
-
Review openjdk/jdk/13393
-
Review openjdk/jdk/13519