Performance hostpot in FieldInterceptionHelper.JavassistDelegate.isInstrumented(Class)

Description

The method

is invoked frequently at runtime, creating a significant performance bottleneck; I'm attaching the profiling report from a synthetic micro benchmark which is unlikely to be representative of a real world case, but able to show a waste of 27% of CPU time in this method only.

From previous discussion:

>
> This is something we should fix in Core; it should be possible to
> associate a "isInstrumented" flag to the Entity, so that we don't need
> to check the class hierarchy at each invocation? I think this should
> reside in the EntityMetamodel, and the
> FieldInterceptionHelper.isInstrumented be invoked only once per type.

Yes, I think it's a good idea. We will still need FieldInterceptionHelper.isInstrumented in some situations where the SessionFActory is unknown but that will help in all the common Hibernate operations.

Attachments

1

Activity

Show:

Brett Meyer March 7, 2014 at 10:09 PM

Bulk closing tickets resolved in released versions

Steve Ebersole December 27, 2011 at 11:15 PM

Another (probably better) option would be to expose something like org.hibernate.bytecode.instrumentation.internal.FieldInterceptionHelper.Delegate from org.hibernate.tuple.entity.EntityTuplizer/org.hibernate.persister.entity.EntityPersister, but have it be (1) BytecodeProvider-specific and (2) class-specific. Something like:

EntityFieldInterceptionDelegate.java

BytecodeProvider.java

etc...

Steve Ebersole December 27, 2011 at 10:40 PM

For example, I see this changeset includes a change to org.hibernate.event.internal.AbstractSaveEventListener#markInterceptorDirty (https://fisheye2.atlassian.com/viewrep/Hibernate-Core/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractSaveEventListener.java?r1=babeacefb0860fa7a04de5bb78700bb109421850&r2=aef27fec4116d6532aebdf1fefdbe89d2f208d38)

which changes:

to:

but why not just change that to:

I have not looked through all the changes, but I cannot imagine there is a time where you have access to this service but do not have access to the EntityPersister especially since the change here states that use of this service is expected only from a SessionFactory

Steve Ebersole December 27, 2011 at 10:32 PM

Hmm, I think this issue might have been easier to fix than what was done here unless I am misunderstanding something.

Why not just delegate to org.hibernate.persister.entity.EntityPersister#isInstrumented ? Seems you are duplicating that information here in this org.hibernate.service.instrumentation.internal.CachingInstrumentationService#isInstrumentedCache cache.

Fixed

Details

Assignee

Reporter

Labels

Fix versions

Priority

Created October 14, 2011 at 8:11 PM
Updated March 7, 2014 at 10:09 PM
Resolved October 17, 2011 at 5:37 PM