[JIRA] (HHH-15616) Mitigate performance impact of entity enhancement on Klass's _secondary_super_cache
by Sanne Grinovero (JIRA)
Sanne Grinovero ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMDc0N2E5MTVm... ) / Improvement ( https://hibernate.atlassian.net/browse/HHH-15616?atlOrigin=eyJpIjoiMDc0N2... ) HHH-15616 ( https://hibernate.atlassian.net/browse/HHH-15616?atlOrigin=eyJpIjoiMDc0N2... ) Mitigate performance impact of entity enhancement on Klass's _secondary_super_cache ( https://hibernate.atlassian.net/browse/HHH-15616?atlOrigin=eyJpIjoiMDc0N2... )
Issue Type: Improvement Assignee: Sanne Grinovero ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) Components: hibernate-core Created: 19/Oct/2022 10:47 AM Priority: Major Reporter: Sanne Grinovero ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
We’ve recently become aware of JDK’s limitation https://bugs.openjdk.org/browse/JDK-8180450 ( https://bugs.openjdk.org/browse/JDK-8180450 ) and an investigation via https://github.com/franz1981/type-pollution-agent/ ( https://github.com/franz1981/type-pollution-agent/ ) revealed that Hibernate ORM is affected via various paths.
One of the most significant areas of concern surrounds the techniques used to handle bytecode enhanced entities; the agent reports the following:
1: io.quarkus.benchmark.model.World
Count: 51703308
Types:
org.hibernate.engine.spi.PersistentAttributeInterceptable
org.hibernate.engine.spi.ManagedEntity
org.hibernate.engine.spi.SelfDirtinessTracker
org.hibernate.engine.spi.Managed
Traces:
org.hibernate.engine.internal.EntityEntryContext.getAssociatedManagedEntity(EntityEntryContext.java:153)
class: org.hibernate.engine.spi.ManagedEntity
count: 12108604
org.hibernate.engine.internal.EntityEntryContext.getAssociatedManagedEntity(EntityEntryContext.java:154)
class: org.hibernate.engine.spi.ManagedEntity
count: 6511885
org.hibernate.property.access.spi.EnhancedSetterImpl.set(EnhancedSetterImpl.java:49)
class: org.hibernate.engine.spi.PersistentAttributeInterceptable
count: 4770509
org.hibernate.tuple.entity.PojoEntityTuplizer.afterInitialize(PojoEntityTuplizer.java:227)
class: org.hibernate.engine.spi.SelfDirtinessTracker
count: 4762608
org.hibernate.tuple.entity.PojoEntityTuplizer.afterInitialize(PojoEntityTuplizer.java:210)
class: org.hibernate.engine.spi.PersistentAttributeInterceptable
count: 3617911
org.hibernate.tuple.entity.PojoEntityTuplizer.afterInitialize(PojoEntityTuplizer.java:228)
class: org.hibernate.engine.spi.SelfDirtinessTracker
count: 3325834
org.hibernate.tuple.entity.BytecodeEnhancementMetadataPojoImpl.extractLazyInterceptor(BytecodeEnhancementMetadataPojoImpl.java:271)
class: org.hibernate.engine.spi.PersistentAttributeInterceptable
count: 2883597
org.hibernate.tuple.entity.PojoEntityInstantiator.applyInterception(PojoEntityInstantiator.java:55)
class: org.hibernate.engine.spi.PersistentAttributeInterceptable
count: 2740804
org.hibernate.engine.internal.StatefulPersistenceContext.clear(StatefulPersistenceContext.java:236)
class: org.hibernate.engine.spi.PersistentAttributeInterceptable
count: 2617366
org.hibernate.property.access.spi.EnhancedSetterImpl.set(EnhancedSetterImpl.java:50)
class: org.hibernate.engine.spi.PersistentAttributeInterceptable
count: 2560881
org.hibernate.tuple.entity.AbstractEntityTuplizer.linkToSession(AbstractEntityTuplizer.java:717)
class: org.hibernate.engine.spi.PersistentAttributeInterceptable
count: 1705389
org.hibernate.engine.internal.StatefulPersistenceContext.clear(StatefulPersistenceContext.java:237)
class: org.hibernate.engine.spi.PersistentAttributeInterceptable
count: 1464702
org.hibernate.engine.internal.EntityEntryContext.addEntityEntry(EntityEntryContext.java:94)
class: org.hibernate.engine.spi.ManagedEntity
count: 1391146
org.hibernate.engine.internal.EntityEntryContext.addEntityEntry(EntityEntryContext.java:96)
class: org.hibernate.engine.spi.ManagedEntity
count: 1242069
org.hibernate.property.access.internal.PropertyAccessStrategyResolverStandardImpl.resolvePropertyAccessStrategy(PropertyAccessStrategyResolverStandardImpl.java:40)
class: org.hibernate.engine.spi.Managed
count: 2
org.hibernate.tuple.entity.PojoEntityInstantiator.<init>(PojoEntityInstantiator.java:38)
class: org.hibernate.engine.spi.PersistentAttributeInterceptable
count: 1
--------------------------
Source code matches Hibernate ORM version 5.6.12.Final - and while the agent is prone to reporting false positives, we believe this is not the case.
This issue has - surprisingly - eluded performance diagnostic tools so far, and yet has very significant impact on performance; scalability is particularly affected as an high number of cache to cache communication is triggered, including via false sharing of the type cache information.
I believe we can, at least partially, mitigage the performance hit via a minor refactoring which could be applied to both ORM 5.6 and 6+; a better and more thourough analysis will follow separately but will not be backported to older ORM versions.
( https://hibernate.atlassian.net/browse/HHH-15616#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-15616#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100209- sha1:5f5cf47 )