[crac] RFR: Register CallSite cleaners with higher priority

Radim Vansa duke at openjdk.org
Fri May 12 10:59:07 UTC 2023


On Fri, 12 May 2023 10:20:41 GMT, Anton Kozlov <akozlov at openjdk.org> wrote:

>> Cleaners for CallSites cannot be registered with regular CLEANERS priority as this would hang/throw exceptions any time a lambda or method reference is used during or after processing this resource priority class; therefore we postpone as the last priority.
>
> src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java line 94:
> 
>> 92:             // CleanerFactory class) until cleanup is performed.
>> 93:             new CleanerImpl.PhantomCleanableRef(cs, CleanerFactory.cleaner(),
>> 94:                     newContext, JDKResource.Priority.CALL_SITES);
> 
> This is based on impl details. Is it possible to use e.g. a `CleanerFactory.criticalCleaner().register(...)` that will use different priorities?

1) `CleanerFactory` could get a new method since it is in `jdk.internal.ref`, but such alternative implementation would spin up another thread.
2) `Cleaner` is a public interface, so I cannot add an alternative method. Regrettably it's also a final class, so I can't make CleanerFactory wrap the common cleaner and override just the `register()` method.

I find that the info that we need to do something different already leaks to MethodHandleNatives and since your suggested solution has impact on memory usage, I would rather choose breaking the encapsulation.

-------------

PR Review Comment: https://git.openjdk.org/crac/pull/66#discussion_r1192216893


More information about the crac-dev mailing list