We have been doing some aggressive profiling and tuning of our application and we have noticed that the highest amount of processing time is spent doing validation. We push a lot of data through, so this isn't a big surprise. But we are surprised when we look at what it appears to be doing during this time.
Depending on the type of workload we are testing, we are seeing 8-50% of execution time spent in this stack trace.
Code:
rank self accum count trace method
1 8.76% 8.76% 352 302193 java.lang.Class.getInterfaces
Code:
TRACE 302193: (thread=200001)
java.lang.Class.getInterfaces(Class.java:Unknown line)
org.hibernate.bytecode.instrumentation.internal.FieldInterceptionHelper$JavassistDelegate.isInstrumented(FieldInterceptionHelper.java:115)
org.hibernate.bytecode.instrumentation.internal.FieldInterceptionHelper.isInstrumented(FieldInterceptionHelper.java:59)
org.hibernate.bytecode.instrumentation.internal.FieldInterceptionHelper.isInstrumented(FieldInterceptionHelper.java:67)
org.hibernate.ejb.util.PersistenceUtilHelper.isLoadedWithoutReference(PersistenceUtilHelper.java:47)
org.hibernate.ejb.HibernatePersistence$1.isLoadedWithoutReference(HibernatePersistence.java:90)
javax.persistence.Persistence$1.isLoaded(Persistence.java:93)
org.hibernate.validator.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:61)
org.hibernate.validator.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:131)
org.hibernate.validator.engine.resolver.SingleThreadCachedTraversableResolver.isReachable(SingleThreadCachedTraversableResolver.java:46)
org.hibernate.validator.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:1242)
org.hibernate.validator.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:448)
Can someone help us understand what might be going on here? Our validation is defined through static xml files that are bundled into our jars, and the java classes are created through Thrift schema definitions and code generation.
This stack trace seems to be on some boundary between Hibernate Validator and other libraries such as ejb and bytecode enablement. But it doesn't look right to us that the app is spending so much time just checking isLoaded and other methods in this stack trace over and over again for the same few classes that we are validating.
Could we be doing something wrong?