<div dir="ltr"><div>Hello all!</div><div dir="ltr"><br></div><div dir="ltr">Em sex., 12 de jan. de 2024 às 14:03, Maurizio Cimadamore <<a href="mailto:maurizio.cimadamore@oracle.com">maurizio.cimadamore@oracle.com</a>> escreveu:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
On 12/01/2024 16:28, 刘希晨 wrote:<br>
> Hi I want to ask a question about using project-panama, I implemented <br>
> a network library using JDK21 with panama-foreign and the performance <br>
> are quite well, since the API will officially release in JDK22, I <br>
> started to migrating my project to using JDK22-ea, and I have a <br>
> question about using Linker.Option.isTrivial(), I noticed that in <br>
> JDK22 it seems to be renamed as Linker.Option.critical(), the javadoc <br>
> says the function should have an extremely short running time in all <br>
> cases, and does not callback into Java. I am pretty sure that it could <br>
> be used on some functions returning constants macro from C, but in <br>
> some cases, I am not quite sure if this option could be used, here are <br>
> some examples:<br></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
It's hard to define a clear boundary - the thing to keep in mind is that <br>
critical() disables GC while the call is active - so you don't want to <br>
run it for a very long time. But if you understand the consequences, you <br>
might be in a better position to judge if that's ok.<br></blockquote><div><br></div><div>May I suggest that the following be added to the Javadoc?</div><div>It is already stated that it is advised that critical downcalls be "extremely fast".</div><div>I suggest adding that they should run in a predictable, "constant" amount of time.</div><div><br></div><div>The notion of what is "fast" is not only subjective, but also empirically difficult to ascertain.</div><div>I remember my time with Swing, when we would naively do stuff in rendering threads that we measured was "fast" during development, but actually depended on external factors, such as for example the response time of a file server (which is being transparently accessed via a file system mapping).</div><div>Syscalls will be perceived as "fast" during development, but have in fact no predictable amount of run time, because they depend on the operating system.</div><div> <br></div></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Pedro Lamarão</div></div></div></div>