[wildfly-dev] performance issue with wildfly and hibernate validator

Jason Greene jason.greene at redhat.com
Fri Sep 12 14:19:58 EDT 2014


On Sep 12, 2014, at 1:15 PM, Scott Marlow <smarlow at redhat.com> wrote:

> Have you looked on the JPA spec mailing lists for clarification about 
> whether the getPersistenceProviders result can be cached or not?  I'll 
> take a look to see if I can find anything.
> 
> On 09/12/2014 11:59 AM, Andrew Schmidt wrote:
>> I've been investigating performance issues with wildfly and hibernate validator.
>> The changes made for this https://issues.jboss.org/browse/AS7-1306  imply the
>> follow from the jpa spec:
>> 
>>   The results of calling the  PersistenceProviderResolverHolder.getPersistenceProviderResolver
>>   and the PersistenceProviderResolver.getPersistenceProviders methods must not be cached.
>> 
>> however, the spec says later on:
>> 
>>   Note that the PersistenceProviderResolver.getPersistenceProviders() method
>>   can potentially be called many times.  It is therefore recommended that the
>>   implementation of this method make use of caching.
>> 
>> My interpretation is that wildfly should be caching the providers and it's the
>> responsibility of the callers to not cache the results.   So the issue AS7-1306 shouldn't
>> have been implemented.
> 
> Good point that the JPA.next specification should pick one (allow 
> caching or not).

I think the spec is consistent, but could be improved to avoid confusion. It says that callers of  PersistenceProviderResolver should not cache the result, but PersistenceProviderResolver can internally cache itself. This makes sense because the container should be able to decide when to change the provider, and if the caller caches this wouldn’t take effect.


> 
>> 
>> The performance penalty of wildfly not caching the implementation of that method in regards to
>> hibernate is that HibernatePersistenceProvider  uses a cache for classes/methods/fields
>> and that cache is blown away on every call to getPersistenceProviders and that
>> happens on every validation of every member of every class.
> 
> The Hibernate implementation of these classes also do the same thing:
> 
> https://github.com/hibernate/hibernate-jpa-api/blob/master/src/main/java/javax/persistence/spi/PersistenceProviderResolverHolder.java#L173
> 
> The Hibernate PersistenceProviderResolverHolder does have a comment that 
> caching should be introduced, whatever that means.
> 
>> 
>> _______________________________________________
>> wildfly-dev mailing list
>> wildfly-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>> 
> 
> _______________________________________________
> wildfly-dev mailing list
> wildfly-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/wildfly-dev

--
Jason T. Greene
WildFly Lead / JBoss EAP Platform Architect
JBoss, a division of Red Hat




More information about the wildfly-dev mailing list