5x Slower Context Switching Between Fiber-vs-Thread

Volkan Yazıcı volkan.yazici at gmail.com
Mon Feb 4 21:16:13 UTC 2019


Hello,

In the attached SlowFiberReport.java, main() calls runThreads() and
runFibers() methods and measures the total time it takes. The former,
runThreads(), creates 50 threads and passes a token sequentially 1e6 times.
Whereas the latter, runFibers(), creates 50 fibers running on a
single-threaded scheduler and again passes a token sequentially 1e6 times.
For synchronization purposes, both approaches use a dedicated Lock and
Condition pair for each thread and fiber, respectively. While I am aware
that it is still early to assess the performance of Loom, I am surprised to
see threads performing ~5x better (6s-vs-30s) compared to fibers in terms
of basic unmount/mount costs. Would anybody mind helping me to understand
the cause of the slowness, please? (I hope I am not doing something brain
dead.)

Best.

*Note:* Using a JDK compiled from 2019-01-20 sources.


More information about the loom-dev mailing list