<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle24
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:987978666;
mso-list-template-ids:-1470493426;}
@list l0:level1
{mso-level-tab-stop:36.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level2
{mso-level-tab-stop:72.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level3
{mso-level-tab-stop:108.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level4
{mso-level-tab-stop:144.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level5
{mso-level-tab-stop:180.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level6
{mso-level-tab-stop:216.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level7
{mso-level-tab-stop:252.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level8
{mso-level-tab-stop:288.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level9
{mso-level-tab-stop:324.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1
{mso-list-id:1601715591;
mso-list-template-ids:747543640;}
@list l1:level1
{mso-level-start-at:3;
mso-level-tab-stop:36.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level2
{mso-level-tab-stop:72.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level3
{mso-level-tab-stop:108.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level4
{mso-level-tab-stop:144.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level5
{mso-level-tab-stop:180.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level6
{mso-level-tab-stop:216.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level7
{mso-level-tab-stop:252.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level8
{mso-level-tab-stop:288.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level9
{mso-level-tab-stop:324.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l2
{mso-list-id:1824589863;
mso-list-template-ids:-1027855448;}
@list l2:level1
{mso-level-tab-stop:36.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l2:level2
{mso-level-tab-stop:72.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l2:level3
{mso-level-tab-stop:108.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l2:level4
{mso-level-tab-stop:144.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l2:level5
{mso-level-tab-stop:180.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l2:level6
{mso-level-tab-stop:216.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l2:level7
{mso-level-tab-stop:252.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l2:level8
{mso-level-tab-stop:288.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l2:level9
{mso-level-tab-stop:324.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="en-NL" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span lang="en-NL" style="mso-fareast-language:EN-US">Hi Robert,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="en-NL" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="en-NL" style="mso-fareast-language:EN-US">You mean using normal threads? We tried that years ago, and performance was awful.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US" style="mso-ligatures:standardcontextual"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="NL" style="mso-ligatures:standardcontextual">Best regards, / Met vriendelijke groet,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="NL" style="mso-ligatures:standardcontextual"> <o:p></o:p></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="mso-ligatures:standardcontextual">Rick Hendricksen</span></b><span lang="EN-US" style="mso-ligatures:standardcontextual"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-ligatures:standardcontextual">Specialist Software Engineering<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="en-NL" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> robert engels <robaho@icloud.com>
<br>
<b>Sent:</b> Wednesday, 21 August 2024 13:42<br>
<b>To:</b> Rick Hendricksen <Rick.Hendricksen@vanderlande.com><br>
<b>Cc:</b> Alan Bateman <Alan.Bateman@oracle.com>; loom-dev@openjdk.org; Dennis van den Berg <Dennis.van.den.Berg@vanderlande.com><br>
<b>Subject:</b> Re: java.lang.ThreadBuilders and java.lang.ThreadBuilders.newVirtualThread() are not public
<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">To clarify, if you are guarding every possible blocking operation, you can easily implement your own continuations/scheduler with locks - you don’t need virtual threads. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-bottom:12.0pt">On Aug 21, 2024, at 6:36 AM, robert engels <<a href="mailto:robaho@icloud.com">robaho@icloud.com</a>> wrote:<o:p></o:p></p>
</blockquote>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><o:p></o:p></p>
<div>
<p class="MsoNormal">If you’re doing this, instead of setting a variable - why not use a semaphore per logical cpu then you can run as many simulations in parallel across as many logical cpus as desired. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-bottom:12.0pt">On Aug 21, 2024, at 6:20 AM, Rick Hendricksen <<a href="mailto:Rick.Hendricksen@vanderlande.com">Rick.Hendricksen@vanderlande.com</a>> wrote:<o:p></o:p></p>
</blockquote>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><span lang="en-NL">Hi Alan,</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="en-NL"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="en-NL">The way we identify simulation related blocking operations is by setting a variable right before parking the thread. The scheduler then checks if that variable is null or not, and if null it was not a simulation related
blocking operation and we wait until we get a simulation related blocking operation. We can get away with this because we know we are running on a single thread.</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="en-NL"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="en-NL">We agree that if the API would have a way to communicate the reason for parking the thread, that would be preferable to setting a variable before parking.</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="en-NL"> </span><o:p></o:p></p>
<div>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="NL">Best regards, / Met vriendelijke groet,</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="NL"> </span><o:p></o:p></p>
<p class="MsoNormal"><b><span lang="EN-US">Rick Hendricksen</span></b><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">Specialist Software Engineering</span><o:p></o:p></p>
</div>
<p class="MsoNormal"><span lang="en-NL"> </span><o:p></o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Alan Bateman <<a href="mailto:alan.bateman@oracle.com">alan.bateman@oracle.com</a>>
<br>
<b>Sent:</b> Wednesday, 21 August 2024 11:17<br>
<b>To:</b> Rick Hendricksen <<a href="mailto:Rick.Hendricksen@vanderlande.com">Rick.Hendricksen@vanderlande.com</a>>;
<a href="mailto:loom-dev@openjdk.org">loom-dev@openjdk.org</a><br>
<b>Cc:</b> Dennis van den Berg <<a href="mailto:Dennis.van.den.Berg@vanderlande.com">Dennis.van.den.Berg@vanderlande.com</a>><br>
<b>Subject:</b> Re: java.lang.ThreadBuilders and java.lang.ThreadBuilders.newVirtualThread() are not public</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<table class="MsoNormalTable" border="0" cellpadding="0" width="100%" style="width:100.0%;background:white">
<tbody>
<tr>
<td style="border:solid #EF7B10 1.0pt;padding:2.25pt 2.25pt 2.25pt 2.25pt">
<p class="MsoNormal" align="center" style="text-align:center"><strong><span style="font-family:"Calibri",sans-serif;color:#EF7B10">Be aware</span></strong><span style="color:#EF7B10">: This email was created outside of Vanderlande. Be cautious of its contents
and <strong><span style="font-family:"Calibri",sans-serif">do not click</span></strong> any links or attachments unless you recognise the sender and know the content is safe.</span><o:p></o:p></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"> <o:p></o:p></p>
<div>
<p class="MsoNormal">On 21/08/2024 09:13, Rick Hendricksen wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="en-NL">Hi Alan,</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="en-NL"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="en-NL">Thanks for taking the time to help us with this issue.
</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="en-NL"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="en-NL">We see three problems with using the default scheduler with maxPoolSize:</span><o:p></o:p></p>
<ol style="margin-top:0cm" start="1" type="1">
<li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo3"><span lang="en-NL">Other virtual threads which are not directly related to the simulation would slow down the simulation</span><o:p></o:p></li><li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo3"><span lang="en-NL">Running multiple simulations in parallel would not be possible</span><o:p></o:p></li></ol>
</blockquote>
<p class="MsoNormal">In that case, parallelism means several VMs, each running with maxPoolSize=1, rather than running several simulations in the same VM at the same time.<br>
<br>
<br>
<br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"> <o:p></o:p></p>
<ol style="margin-top:0cm" start="3" type="1">
<li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo3"><span lang="en-NL">We need full control over which thread runs, and how to treat yield. If the thread is yielding because of a simulation-related blocking operation, we want to run
the next thread. If it’s yielding due to IO, we don’t want to switch to another thread. If IO wait would result in a yield, that would be unpredictable, and would affect the result of our simulation.</span><o:p></o:p></li></ol>
<p class="MsoNormal"><span lang="en-NL"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="en-NL">It would be very helpful for us if custom schedulers would be exposed. Could you tell us more about the explorations you mentioned? And is it an option to take our use case into account there?</span><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
</blockquote>
<p class="MsoNormal">There are two explorations at this time. One is allowing the scheduler be selected at virtual Thread create time, like the prototype API on the builder that was in EA builds for a long time but didn't get any feedback. One of the use-cases
for this is servers that want to use their own event loop thread as a carrier to avoid hand-off. The other exploration is exposing a way to replace the system-wide scheduler for servers that want to manage their own thread pool rather than use a work stealing
scheduler. We talked about this a bit at JVMLS 2024, I think the recordings will be posted soon.
<br>
<br>
Note that the problem space and the possible interface for custom schedulers is larger than might initially seem. You touched on exposing the "reason" for preemption and that is one of several things that a scheduler may need to be notified of. One thing that
would be useful to know from your experiments is how you distinguish between your "<span lang="en-NL">simulation-related blocking operation" and the dozens of other possible cases where a thread may be preempted.</span><br>
<br>
In any case, the summary on this topic is that it is being explored again but proceeding with great caution.<br>
<br>
-Alan<o:p></o:p></p>
</div>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="3" width="100%" noshade="" style="color:#EF7B10" align="center">
</div>
<p><span style="font-size:9.0pt">** Disclaimer **<o:p></o:p></span></p>
<p><span style="font-size:9.0pt">This e-mail, including any attachments, may include proprietary and confidential information of Vanderlande and may only be read by the person or those persons to whom it is addressed.
<br>
This document is forwarded to you in such a form (e-mail) that Vanderlande cannot guarantee the completeness and/or correctness of its contents and information.
<br>
If you have received this e-mail message in error, please notify us immediately. <br>
Please also delete this document from your computer. <br>
This document may not be reproduced, copied, distributed, published, modified, or furnished to third parties, without the prior written consent of Vanderlande.<o:p></o:p></span></p>
</div>
</blockquote>
</div>
</blockquote>
</div>
</body>
</html>