-
Bug
-
Resolution: Unresolved
-
P4
-
17.0.7, 21
We see a performance refression after migrating from JDK 8 to JDK 17/21. Similarly to JDK-8305670, the regression is related to Thread-SMR and a large number of background (idle) threads. Async-profiler shows the most time is spent in ThreadsSMRSupport::free_list called from JVM_StartThread - see attached JVM_StartThread.png.
I'm attaching the JMH benchmark that demonstrates the issue: ThreadStart.java
On JDK 8, the performance of Thread.start does not depend much on the number of threads:
Benchmark (threadCount) Mode Cnt Score Error Units
ThreadStart.threadStart 0 avgt 5 0.072 ± 0.006 ms/op
ThreadStart.threadStart 1000 avgt 5 0.073 ± 0.003 ms/op
ThreadStart.threadStart 10000 avgt 5 0.079 ± 0.007 ms/op
ThreadStart.threadStart 30000 avgt 5 0.088 ± 0.009 ms/op
However, on JDK 21, the latency of Thread.start degrades significantly with the number of idle threads:
Benchmark (threadCount) Mode Cnt Score Error Units
ThreadStart.threadStart 0 avgt 5 0.088 ± 0.002 ms/op
ThreadStart.threadStart 1000 avgt 5 0.111 ± 0.007 ms/op
ThreadStart.threadStart 10000 avgt 5 0.391 ± 0.024 ms/op
ThreadStart.threadStart 30000 avgt 5 0.828 ± 0.026 ms/op
The reason of a slowdown is a linear scan in ThreadsSMRSupport::free_list.
I'm attaching the JMH benchmark that demonstrates the issue: ThreadStart.java
On JDK 8, the performance of Thread.start does not depend much on the number of threads:
Benchmark (threadCount) Mode Cnt Score Error Units
ThreadStart.threadStart 0 avgt 5 0.072 ± 0.006 ms/op
ThreadStart.threadStart 1000 avgt 5 0.073 ± 0.003 ms/op
ThreadStart.threadStart 10000 avgt 5 0.079 ± 0.007 ms/op
ThreadStart.threadStart 30000 avgt 5 0.088 ± 0.009 ms/op
However, on JDK 21, the latency of Thread.start degrades significantly with the number of idle threads:
Benchmark (threadCount) Mode Cnt Score Error Units
ThreadStart.threadStart 0 avgt 5 0.088 ± 0.002 ms/op
ThreadStart.threadStart 1000 avgt 5 0.111 ± 0.007 ms/op
ThreadStart.threadStart 10000 avgt 5 0.391 ± 0.024 ms/op
ThreadStart.threadStart 30000 avgt 5 0.828 ± 0.026 ms/op
The reason of a slowdown is a linear scan in ThreadsSMRSupport::free_list.
- relates to
-
JDK-8305670 Performance regression in LockSupport.unpark with lots of idle threads
- Resolved
-
JDK-8340547 Starting many threads can delay safepoints
- Resolved