Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: L2 cache performance with echache got worse from 3.6 to 5.1
PostPosted: Thu Nov 09, 2017 6:21 am 
Newbie

Joined: Thu Nov 09, 2017 6:14 am
Posts: 2
Recently upgraded from 3.6 to 5.1 application and L2 cache performance got significantly slow
My case is a cached query that hits n+1 objects (intentionally so it can heat the cache)
First time load is approx 15 ms for each object and cache stats show the appropriate number of miss and puts
Second time load also shows however 15 ms for each object, however the DB is not it and stats show the appropriate number of hits
using 3.6 second time load shows 0 to 1 ms for each row
Query cache is enabled, also entities that are fetched are cached and I can observe in the stats that numbers prove that both query cache and L2 cache are working

Does this make sense? What's even funnier is that when I start the second load I observe 10 ms growing up to 15 for each cache hit. I have to cache hits - one in the query cache and another in the L2 cache. None of this is observable with 3.6 code

Did something significantly change between 3.6 and 5.1? Don't want to go to 5.2 yet


Top
 Profile  
 
 Post subject: Re: L2 cache performance with echache got worse from 3.6 to 5.1
PostPosted: Thu Nov 09, 2017 7:55 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1582
Location: Romania
Try with a Profiler and see where the additional cost comes from. Maybe it's in the EhCache code? You can't know without profiling it.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: L2 cache performance with echache got worse from 3.6 to 5.1
PostPosted: Thu Nov 09, 2017 10:18 am 
Newbie

Joined: Thu Nov 09, 2017 6:14 am
Posts: 2
The performance hit happens only in a transaction
if I have something like
Code:
begin
    session.beginTransaction()
    doWorkThatInvolvesQueryAndL2Cache() <-- this is slow
    session.commit();
    session.close()
end


However if I just have
Code:
begin
    doWorkThatInvolvesQueryAndL2Cache() <-- this is FAST
    session.close()
end


The core reason that I have transaction around some code that reads data is that some of this code uses .scroll() and scroll.next may fail by closing the result set if it is not in transaction in Hibernate 5 apparently..

Does it make any sense? Am I missing something when doing scroll??


Top
 Profile  
 
 Post subject: Re: L2 cache performance with echache got worse from 3.6 to 5.1
PostPosted: Thu Nov 09, 2017 11:24 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1582
Location: Romania
That doesn't look profiling. Use a profiler to pinpoint what exactly is causing your bottleneck.

Hibernate 5.x is used by thousands of projects without any issue, so you need to profile your application to get more insight into the issue.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.