I have implemented a cache consisting of a bunch of AVL tres and some RoaringBitmaps. This cache stores the data which is read from the database at the application startup, thereafter the data base is not contacted and all requests are served from the above cache. these AVL trees and bitmaps are Java objects that are instantiated once, like say using the singleton pattern. I have noticed that the speed to fetch data from the cache is slow, it gets faster if the same query is repeated again and again and again, but the first query for each unique requests is slow. I suspect some problem with GC pauses and some other issues with long living objects. Do you have any thoughts around this ?
Asked
Active
Viewed 1,020 times
1 Answers
0
If you run on a server VM, you might, in general, see the effect that the application gets faster after some usage, see: Real differences between "java -server" and "java -client"?
Do you have GC pauses? How should the people in the internet know?! Please consult: Java Garbage Collection Log messages
-
thanks @cruftex I actually don't fully understand why the garbage collector would play a role in slowing things down, sorry my bad I don't understand it well – hershey92 Jul 26 '15 at 21:03
-
About the server VM, this is the VM name I get when printing it, "Dynamic Code Evolution 64-Bit Server VM" If the effect does happen in this launch configuration is there a way I can pre load or do some configuration that this kind of lazy loading thing doesn't happen and every request is just as fast as the previous. – hershey92 Jul 26 '15 at 21:04
-
Yes of course. You can switch off the JIT at all. Then everything is damn slow, but always as fast as the previous request. During execution the VM learns about the runtime characteristics of your code. You should feel lucky and thankful, that your code gets executed faster :) Please follow link in the articles I linked above. You will find more information on how to tune things. – cruftex Jul 26 '15 at 21:22
-
BTW: "Dynamic Code Evolution 64-Bit Server VM" how did you get VM? Maybe it makes sense to include your OS and "java -version" in the question. Sorry, the documentation on server and client VM does not apply. This is for the Oracle JDK HotSpot VM. Maybe you should experiment with different JDKs? – cruftex Jul 26 '15 at 21:29