RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v10]

Adam Sotona asotona at openjdk.org
Thu Jun 8 16:11:49 UTC 2023


On Thu, 8 Jun 2023 14:07:24 GMT, Brian Goetz <briangoetz at openjdk.org> wrote:

>  Here are a few options: 
 - Make the CHA cache thread-safe using, say, CHM; 

This is current solution for the default system CH cache. 

We may also use a bit less strict custom semi-synchronization (just enough to be thread safe) instead of fully-synchronized `CHM::computeIfAbsent`, for example `CHM:get … (compute if absent without lock) ... CHM::put`.
CHM does not lock on get, so the only penalty would be synchronous put call. 

> - Make the CHA cache unshared, by using a ThreadLocal (this brings the context back to being immutable)

This is interesting option for small number of threads, however it makes big footprint for heavy-parallel systems.

> - Detect when implicit use of a context happens on a thread other than the creating thread (currently the only vector for this is Classfile::transform), and inflate a new context with empty cache in that case;

This would degrade the caching completely by triggering a new context for each transformed method in case there are two threads working synchronously.

> - Always create a fresh context with an empty cache in Classfile::transform

This would destroy the caching. Such cache would work only in scope of one method.

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

PR Comment: https://git.openjdk.org/jdk/pull/14180#issuecomment-1582943385


More information about the core-libs-dev mailing list