[External] : Re: Experience using virtual threads in EA 23-loom+4-102
Ron Pressler
ron.pressler at oracle.com
Sat Jul 6 21:05:11 UTC 2024
> On 6 Jul 2024, at 21:23, Ron Pressler <ron.pressler at oracle.com> wrote:
>
>
> There are bigger problems than deadlocks if you use spin loops — with or without time sharing — when you have many thousands of threads.
Actually, let me elaborate a bit more about this, and from your question I fear that someone may be using spinlocks when they shouldn’t: Spinlocks are only effective when the lock is held for very short durations, which typically means some computation — not IO. When that’s the case, time sharing is irrelevant, as the owner thread is still scheduled to a core. If that’s not the case, i.e. the owner thread is doing some blocking IO operation, then a spinlock would just thrash your CPU for nothing, having a negative impact on throughput. Having a large number of threads would exacerbate the effect, and time sharing won’t solve the problem (imagine thousands of threads getting a significant CPU time slice to do nothing but thrash before the owner is finally selected by the scheduler). Rather, the right solution is not to use a spinlock in such situations.
In other words, when a spinlock is actually appropriate, it will be just as effective without time-sharing.
— Ron
More information about the loom-dev
mailing list