Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Comparing JVM Virtual Threads vs. Real Threads in Clojure (github.com/bryanmikaelian)
6 points by bryanmikaelian 8 months ago | hide | past | favorite | 1 comment
I wrote this just to compare the performance of Java 21 Virtual Threads vs old-fashioned Threads.



A couple of issues:

- The code ends up using reflection. Try `(set! *warn-on-reflection* true)` to see the warnings so you can fix them

- The vthreads code starts time measurement, then creates and starts the threads, then joins, then ends the measurement. But the rthreads code first creates the threads, then starts the measurement, then starts the threads, then never joins. You end up comparing apples to oranges

The results on my machine, after the fixes:

  virtual elapsed time (ms):  90
  real elapsed time (ms):  45
Of course, it's still a microbenchmark and as such shouldn't be taken seriously for anything but hypothesis generation.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: