<div dir="ltr"><div dir="ltr">I do happen to have an executor framework in which all this is trivial to implement, because you just need to implement a single submit method, and the rest you can get for free (as in you don't have to implement it) using a single call: `TaskExecutors.upgradeToStoppable(executor)` (though this returns an instance of my `TaskExecutorService` interface, but I have bridge methods to convert that to `ExecutorService` with minimal overhead). See <a href="https://javadoc.io/doc/org.jtrim2/jtrim-executor/latest/jtrim.executor/org/jtrim2/executor/package-summary.html">https://javadoc.io/doc/org.jtrim2/jtrim-executor/latest/jtrim.executor/org/jtrim2/executor/package-summary.html</a> If you want to give it a try, you can send me a personal email, and I can answer API specific questions.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Colin Redmond <<a href="mailto:Colin.Redmond@outlook.com">Colin.Redmond@outlook.com</a>> ezt írta (időpont: 2024. máj. 13., H, 23:54):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg-7526258049448489074">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
If it is safe to keep virtual threads and pool them, there is still a net benefit to pooling virtual threads. I agree a major benefits of virtual threads is that they are cheap to create, so there is no
<b>need </b>to pool them. But the memory and performance increase even pooling is no small matter.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
In my case I have 500 platform threads I am limited because my container is small and they start to use a significant portion of the memory. I switch them for 1000 virtual threads, this saves me ~ 500 mb of RAM (maybe less i didn't do the math). Between less
need for context switching and more memory for garbage, I am still seeing a 20 - 30% improvements. Which even with pooled virtual threads is a big improvement.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Firstly I was hoping there was an existing solution, I googled it a while but couldn't find any specific open source packages if anyone knows any let me know, I would prefer to import something. If not I may continue my journey of writing a new ExecutorService
for my use case. <br></div><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left:1px solid rgb(204,204,204)">
</blockquote>
</div>
</div></blockquote></div></div>