taming resource scopes

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Sat May 29 17:07:51 UTC 2021


On 29/05/2021 16:07, Radosław Smogura wrote:
> Hi Maurizio,
>
> Thank you this looks very interesting. I’ll try to integrate it with pooled allocator - I think there should be no issues nor huge performance degradation.
>
>  From the other hand, I read the article and a and took a look at the pool request.

I already did some work to merge your work with the prototype, and it 
actually gains few nanoseconds. That's because we no longer need to 
bother with releasing the same handle multiple times, so there are 
slightly less checks.


>
> I wonder if some, mentioned performance concern related to SharedScope can’t be mitigated. I think the aliveness checks (volatile state check) when calling addCloseDroendency are executed twice - once when calling this method and once with acquire. Just a micro optimization observation.

Yeah - something can be improved, however the big cost comes from the 
CAS to acquire the counter and increment atomically.

Maurizio

>
> Kind regards,
> Rado
>
>> On May 28, 2021, at 6:35 PM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
>>
>> Hi,
>> we've been looking beyond 17 at things we can do to improve support for resource scopes, especially in the context of native calls. I tried to capture the various things we explored in the writeup below:
>>
>> https://urldefense.com/v3/__https://inside.java/2021/05/28/taming-resource-scopes/__;!!GqivPVa7Brio!JuxuGNyOxp3cvPBmUynQF6JTZVRBuSwna1W3h9llMiq9XtRgzhQGw_GG-TC_T4TfrDlmENY$
>>
>> I think overall the takeaway points are pretty good:
>>
>> * we can simplify the acquire/release scope mechanism with a better, higher-level API
>> * we can enhance safety when calling native functions using _any kind_ of resource scopes (with relatively little overhead)
>> * we can make it easier to tailor the safety characteristics of CLinker to suit application needs
>>
>> Cheers
>> Maurizio
>>


More information about the panama-dev mailing list