[External] : Re: Performance of pooling virtual threads vs. semaphores
Ron Pressler
ron.pressler at oracle.com
Thu Jun 6 01:02:35 UTC 2024
> On 5 Jun 2024, at 22:58, robert engels <rengels at ix.netcom.com> wrote:
>
> Hi Ron,
>
> When you say "most submissions would be internal” is that under the assumption that in a thread per request model, the number of times the thread “blocks” would X for each request, meaning there would be N*X internal submissions for every N requests.
>
> So if you had requests with a low number of blocks (context switches) then pooling the virtual threads would be better?
>
No, virtual threads should never be pooled.
I can’t even know if external submissions play a role in the behaviour difference here, only this microbenchmark doesn’t resemble the intended realistic workload in that regard and it’s very hard to extrapolate from microbenchmarks.
If this aspect does cause a significant difference, then if that patterns happens to be common in realistic workloads, then we’ll have a reason to properly profile them and then change the scheduling algorithm accordingly. In any event, you should never write less idiomatic code to exploit an accidental and undocumented — and therefore quite possibly a temporary one.
Idiomatic code is always more likely to be the target of future improvement, and unidiomatic code is more likely to suffer because it’s less likely to be profiled and optimised. From time to time we see some strange code that’s causing an issue and we ask the authors why they wrote code like that and they say that it’s to enjoy some benefit due to some undocumented implementation detail of the runtime’s, only that implementation changed three years ago...
— Ron
More information about the loom-dev
mailing list