[9, 8u40] RFR (M): 8057020: LambdaForm caches should support eviction

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Mon Dec 1 16:58:31 UTC 2014


There are 2 major LambdaForm caches: LambdaFormEditor-based and 
MethodTypeForm. The former is per-LambdaForm and the latter is per 
method type erased to basic types. The problem is that these caches 
don't support eviction, so they can hold LambdaForms forever.

Usually, it's not a problem since an application has very limited number 
of unique erased method types (e.g. on Octane/Nashorn it varies 1,5-3k 

The fix is to use SoftReferences to keep LambdaForms alive as long as 
possible, but avoid throwing OOME until the caches are evicted. I 
experimented with WeakReferences, but it doesn't hold LambdaForms for 
long enough: LambdaForm cache hit rate degrades significantly and it 
negatively affects application startup and warmup, since every 
instantiated LambdaForm is precompiled to bytecode before usage.

Testing: jdk/java/lang/invoke/LFCache in stress mode + jck 
(api/java_lang/invoke), jdk/java/lang/invoke, jdk/java/util/streams, octane


Best regards,
Vladimir Ivanov

More information about the core-libs-dev mailing list