Question about Linker.Option.isTrivial()

Pedro Lamarão pedro.lamarao at prodist.com.br
Fri Jan 12 19:34:34 UTC 2024


Hello all!

Em sex., 12 de jan. de 2024 às 14:03, Maurizio Cimadamore <
maurizio.cimadamore at oracle.com> escreveu:

>
> On 12/01/2024 16:28, 刘希晨 wrote:
> > Hi I want to ask a question about using project-panama, I implemented
> > a network library using JDK21 with panama-foreign and the performance
> > are quite well, since the API will officially release in JDK22, I
> > started to migrating my project to using JDK22-ea, and I have a
> > question about using Linker.Option.isTrivial(), I noticed that in
> > JDK22 it seems to be renamed as Linker.Option.critical(), the javadoc
> > says the function should have an extremely short running time in all
> > cases, and does not callback into Java. I am pretty sure that it could
> > be used on some functions returning constants macro from C, but in
> > some cases, I am not quite sure if this option could be used, here are
> > some examples:
>


> It's hard to define a clear boundary - the thing to keep in mind is that
> critical() disables GC while the call is active - so you don't want to
> run it for a very long time. But if you understand the consequences, you
> might be in a better position to judge if that's ok.
>

May I suggest that the following be added to the Javadoc?
It is already stated that it is advised that critical downcalls be
"extremely fast".
I suggest adding that they should run in a predictable, "constant" amount
of time.

The notion of what is "fast" is not only subjective, but also empirically
difficult to ascertain.
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).
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.

-- 
Pedro Lamarão
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20240112/4cbca0a7/attachment-0001.htm>


More information about the panama-dev mailing list