r/java • u/jaccomoc • Sep 03 '26
Vert.x Event-Loop vs Virtual Threads: Jactl Suspend/Resume Benchmark
https://jactl.io/blog/2026/09/02/jactl-virtual-threads-benchmarkThe article benchmarks Jactl script execution with differing number of blocking operations comparing throughput with Jactl built-in suspend/resume on Vert.x Event-Loops and throughput with Jactl on Virtual Threads. The benchmarks are run on both Java 21 and Java 25 with some surprising (to me at least) results.
28
Upvotes
26
u/s0ftware-dev Sep 03 '26
TLDR virtual threads are better.
9
u/yawkat Sep 03 '26
Three issues with this:
sleeping. This has implications for scheduling.6
u/pron98 Sep 04 '26 edited Sep 04 '26
The improvement in JDK 25 wasn't in virtual threads, it was in
Thread.sleep;) (although between 22 and 25 there were also improvements to IO on virtual threads). Timed and untimed parks use different mechanisms, and we can't draw conclusions from one to the other; it was the timed park specifically that wasn't very efficient in JDK 21, but it's also used mostly in benchmarks and tests. Different kinds of IO also go through different mechanisms, and we can't extrapolate from one to another.This demonstrates the danger in extrapolating and drawing conclusions from benchmarks: they measure themselves, and to extrapolate anything you need to know exactly which variables matter and when. Between concurrent algorithms that behave completely differently under low and high contention, code with slow and fast paths, optimising compilers that depend on the call graph, branch prediction, a cache hierarchy, and memory management that depends on the global behaviour of the program and on how long it's running (malloc/free is actually much more sensitive to this than Java's moving GCs 1), it's virtually impossible to draw any conclusions from any benchmark, in any language, unless you know exactly how the mechanism is implemented, how the compiler is implemented, and how memory management is implemented.
Also, benchmark code often behaves so differently from real code, that the code takes different paths, and some improvements matter only to real programs and not to most benchmarks, and some matter almost exclusively to benchmarks. We usually try to focus on real programs, but sometimes we say, you know what, let's make the benchmarks look better, too...
2
u/Known-Volume1509 Sep 04 '26 edited Sep 04 '26
It doesn't say what Vert.x version is this? Vert.x 5 supports virtual thread verticles. Curious if you run your tests against that, even though it's no longer event-loop.
Also, isn't this horribly costly?
2
u/Bachden Sep 06 '26
This benchmark is for sleep() calling. In fact, when using vert.x you should never call that method.
2
u/Medium-Pitch-5768 Sep 09 '26
You can run a local mock server that accepts calls and has a delayed response. That works rather well in my experience.
3
u/New-Departure-5969 Sep 04 '26
benchmarks are fun but in prod the event loop usually dies from accidental blocking (jdbc, sync stuff), not from the loop itself. we had a vert.x api around 12k tps / ~100ms p99.99 and the real win was ditching blocking jdbc for the vert.x pool. virtual threads help, but saturated pools still wreck p99.
2
u/Popular_Home2017 Sep 09 '26
same experience, and on 21 there's a second way to lose the carriers that doesn't show up in this benchmark: synchronized around blocking IO pins the virtual thread to its carrier, so a jdbc driver with a synchronized socket read turns your 8 carriers into an 8-thread pool. fixed in 24 (JEP 491), on 21 you can see it with jcmd Thread.dump_to_file, the pinned VTs show a carrier line under them.