Question about Linker.Option.isTrivial()

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Fri Jan 12 21:46:47 UTC 2024


On 12/01/2024 19:34, Pedro Lamarão wrote:
> 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.
I agree that the text could be improved - however we don't say "fast" - 
we say this:


> A critical function is a function that has an extremely short running 
> time in all cases (similar to calling an empty function), and does not 
> call back into Java (e.g. using an upcall stub).
>

I agree that talking about "constant" or "predictable" execution time 
would perhaps be a better characterization.

Maurizio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20240112/29a47c9c/attachment.htm>


More information about the panama-dev mailing list