-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Cache question, interesting...
PostPosted: Sun Feb 27, 2011 10:06 pm 
Newbie

Joined: Sun Sep 14, 2008 11:37 pm
Posts: 2
I have set up a cache of read-only data. This data never changes, well it does, but not while the app in question is running so 'never' is close enough.
The app runs okay, that isn't the problem, but it behaves strangely when I switch databases.

Second level cache is on, so is query cache. I'm using annotated classes and they all have this:
[code]
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY,region="product2Cache")
[/code]
I have an ehcache.xml file in the classpath, it looks like this:
[code]
...
<cache name="product2Cache"
maxElementsInMemory="100000"
eternal="true"
overflowToDisk="false"
memoryStoreEvictionPolicy="LFU"/>
...
[/code]
My understanding is that everything the application reads will now be cached forever.
To this end at startup I run some hefty queries to load as much as I can into the cache, that way the online users don't need to wait. All their queries will be on the cache, not the database.

Okay so I run some tests using Oracle (dialect=Oracle10gDialect)
[code]
14:37:11.549 RecommendationPerformance - performanceScenario1 timer: 25873
14:37:35.533 RecommendationPerformance - performanceScenario2 timer: 23968
14:37:59.519 RecommendationPerformance - performanceScenario3 timer: 23982
14:38:23.174 RecommendationPerformance - performanceScenario4 timer: 23652
14:38:23.177 RecommendationPerformance - [ name = org.hibernate.cache.StandardQueryCache cacheHits = 0 onDiskHits = 0 inMemoryHits = 0 misses = 0 size = 0 averageGetTime = 0.0 evictionCount = 0 ]
14:38:23.177 RecommendationPerformance - [ name = product2Cache cacheHits = 1753 onDiskHits = 0 inMemoryHits = 1753 misses = 16 size = 938 averageGetTime = 0.012549914 evictionCount = 0 ]
14:38:23.177 RecommendationPerformance - [ name = org.hibernate.cache.UpdateTimestampsCache cacheHits = 0 onDiskHits = 0 inMemoryHits = 0 misses = 0 size = 0 averageGetTime = 0.0 evictionCount = 0 ]
[/code]
The four scenarios do the same thing and they take about the same amount of time each. I'm not quite sure what the cache numbers being reported are but clearly the product2Cache is doing something.

Now, with the exactly the same setup, I change from Oracle to HSQL (dialect=HSQLDialect) using an in-memory configuration. I load the same data into memory before the test starts using JDBC (no no ehcache invoked) and I also still run the same cache population code I used in the previous test. Here we go:
[code]
14:34:56.937 RecommendationPerformance - performanceScenario1 timer: 1856
14:34:57.773 RecommendationPerformance - performanceScenario2 timer: 807
14:34:58.644 RecommendationPerformance - performanceScenario3 timer: 869
14:34:59.003 RecommendationPerformance - performanceScenario4 timer: 357
14:34:59.005 RecommendationPerformance - [ name = org.hibernate.cache.StandardQueryCache cacheHits = 0 onDiskHits = 0 inMemoryHits = 0 misses = 0 size = 0 averageGetTime = 0.0 evictionCount = 0 ]
14:34:59.005 RecommendationPerformance - [ name = product2Cache cacheHits = 896 onDiskHits = 0 inMemoryHits = 896 misses = 9 size = 109 averageGetTime = 0.0078125 evictionCount = 0 ]
14:34:59.005 RecommendationPerformance - [ name = org.hibernate.cache.UpdateTimestampsCache cacheHits = 0 onDiskHits = 0 inMemoryHits = 0 misses = 0 size = 0 averageGetTime = 0.0 evictionCount = 0 ]
[/code]
I much prefer those timings! But I don't understand why they are so different from the Oracle ones. Surely after the first scenario everything ought to be cached (this is true even if my prepopulation code is rubbish). So I expected that the first test timing would be similar to the second from Scenaro2 onwards. I also expect the cache stats would be the same (maybe not the averageGetTime, though).

Can someone tell me where I've misunderstood this?
Thanks
Roger
(Hibernate-3.2.6.ga, Oracle 10.2.0.1.0, HSQLDB 1.8.0, ehcache 1.4.1)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.