<div dir="ltr">Hello again,<div><br></div><div>As promised, here is my second (shorter I hope!) email sharing feedback on the recent Loom EA build (23-loom+4-102). If follows up on my previous email <a href="https://mail.openjdk.org/pipermail/loom-dev/2024-June/006788.html">https://mail.openjdk.org/pipermail/loom-dev/2024-June/006788.html</a>.</div><div><br></div><div>I performed some experiments using the same application described in my previous email. However, in order to properly test the improvements to Object monitors (synchronized blocks and Object.wait()) I reverted all of the thread-pinning related changes that I had made in order to support virtual threads with JDK21. Specifically, I reverted the changes converting uses of monitors to ReentrantLock.</div><div><br></div><div>I'm pleased to say that this EA build looks extremely promising! :-) </div><div><br></div><div>### Experiment #1: read stress test</div><div><br></div><div>* platform threads: 215K/s throughput, CPU 14% idle</div><div>* virtual threads: 235K/s throughput, CPU 5% idle.</div><div><br></div><div>Comment: there's a slight throughput improvement, but CPU utilization is slightly higher too. Presumably this is due to the number of carrier threads being closely matched to the number of CPUs (I noticed significantly less context switching with v threads).</div><div><br></div><div>### Experiment #2: heavily indexed write stress test, with 40 clients</div><div><br></div><div><div>* platform threads: 9300/s throughput, CPU 27% idle</div><div>* virtual threads: 8800/s throughput, CPU 24% idle.</div><div><br></div></div><div>Comment: there is a ~5% performance degradation using virtual threads. This is better than the degradation I observed in my previous email after switching to ReentrantLock though.</div><div><br></div><div><div>### Experiment #3: extreme heavy indexed write stress test, with 120 clients</div><div><br></div><div><div>* platform threads: 1450/s throughput</div><div>* virtual threads: 1450/s throughput (i.e. about the same).</div></div></div><div><br></div><div>Comment:</div><div><br></div><div>This test is intended to stress the internal locking mechanisms as much as possible and expose any pinning problems.</div><div>With JDK21 virtual threads the test would sometimes deadlock and thread dumps would show 100+ fork join carrier threads.</div><div>This is no longer the case with the EA build. It looks really solid.</div><div><br></div><div>This test does expose one important difference between platform threads and virtual threads though. Let's take a look at the response times:</div><div><br></div><div>Platform threads:</div><div><br></div><div>-------------------------------------------------------------------------------<br>|     Throughput    |                 Response Time                |          | <br>|    (ops/second)   |                (milliseconds)                |          | <br>|   recent  average |   recent  average    99.9%   99.99%  99.999% |  err/sec | <br>-------------------------------------------------------------------------------<br>...<br>|   1442.6   1606.6 |   83.097   74.683   448.79   599.79   721.42 |      0.0 | <br>|   1480.8   1594.0 |   81.125   75.282   442.50   599.79   721.42 |      0.0 |</div><div><br></div><div>Virtual threads:</div><div><br></div><div> -------------------------------------------------------------------------------<br></div>|     Throughput    |                 Response Time                |          | <br>|    (ops/second)   |                (milliseconds)                |          | <br>|   recent  average |   recent  average    99.9%   99.99%  99.999% |  err/sec | <br>-------------------------------------------------------------------------------<br>...<br>|   1445.4   1645.3 |   81.375   72.623  3170.89  4798.28  8925.48 |      0.0 | <br>|   1442.2   1625.0 |   81.047   73.371  3154.12  4798.28  6106.91 |      0.0 | <div><br></div><div>The outliers with virtual threads are much much higher. Could this be due to potential starvation when rescheduling virtual threads in the fork join pool?</div><div><br></div><div>Cheers,</div><div>Matt</div><div><br></div></div>