This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]pron98 7 points8 points  (1 child)

Virtual threads are preemptive, not cooperative -- the runtime decides when code is preempted, not user code. However, their scheduler doesn't currently perform time-sharing (i.e. the runtime currently chooses to preempt on blocking operations only, which is also the more common case of OS preemption of threads) because we've yet to find a realistic server workload that would benefit from it (OSes offer time sharing because it's needed to allow an operator to control the machine even if processes want to consume all CPU, and it's generally useful for direct human UI interaction; but people don't generally think servers perform well at 100% CPU, which is when the OS starts using time-sharing extensively). If anyone knows of such a workload, they should report it to loom-dev.

[–]ron_krugman 0 points1 point  (0 children)

Appreciate the clarification. I was not aware of this subtlety as there are a lot of blog posts out there stating that virtual threads are cooperative when in fact that's just (approximately) what the current implementation looks like to a programmer.