[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-6735) Performance hostpot in FieldInterceptionHelper.JavassistDelegate.isInstrumented(Class)
Steve Ebersole (JIRA)
noreply at atlassian.com
Tue Dec 27 15:42:19 EST 2011
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6735?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44732#comment-44732 ]
Steve Ebersole commented on HHH-6735:
-------------------------------------
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:
{code}
private void markInterceptorDirty(Object entity, EntityPersister persister, EventSource source) {
if ( FieldInterceptionHelper.isInstrumented( entity ) ) {
FieldInterceptor interceptor = FieldInterceptionHelper.injectFieldInterceptor(
entity,
persister.getEntityName(),
null,
source
);
interceptor.dirty();
}
}
{code}
to:
{code}
private void markInterceptorDirty(Object entity, EntityPersister persister, EventSource source) {
InstrumentationService instrumentationService = persister.getFactory()
.getServiceRegistry()
.getService( InstrumentationService.class );
if ( instrumentationService.isInstrumented( entity ) ) {
FieldInterceptor interceptor = FieldInterceptionHelper.injectFieldInterceptor(
entity,
persister.getEntityName(),
null,
source
);
interceptor.dirty();
}
}
{code}
but why not just change that to:
{code}
private void markInterceptorDirty(Object entity, EntityPersister persister, EventSource source) {
if ( persister.isInstrumented() ) {
FieldInterceptor interceptor = FieldInterceptionHelper.injectFieldInterceptor(
entity,
persister.getEntityName(),
null,
source
);
interceptor.dirty();
}
}
{code}
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}}
> Performance hostpot in FieldInterceptionHelper.JavassistDelegate.isInstrumented(Class)
> --------------------------------------------------------------------------------------
>
> Key: HHH-6735
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6735
> Project: Hibernate Core
> Issue Type: Improvement
> Reporter: Sanne Grinovero
> Assignee: Emmanuel Bernard
> Fix For: 4.0.0.CR5
>
> Attachments: HibernateCore Hot spots.tar.gz
>
>
> The method {code}org.hibernate.bytecode.instrumentation.internal.FieldInterceptionHelper.JavassistDelegate.isInstrumented(Class){code} 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:{quote}>
> > 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.{quote}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list