Hibernate query caching
Looks like my efforts to make BlogBuilder more efficient by caching more queries has caused me some unforseen trouble.
We had what appeared to be deadlocking in the application the other day. Doing a thread dump (thank god for "kill -3"), we saw that all of the threads were blocked in SoftLimitMRUCache.
Turns out it is a bug Concurrent access issues with both SoftLimitMRUCache and SimpleMRUCache
We were hitting the caches so much that a subtle hibernate bug appeared. We'll await a fix, but in the meantime I'm trying to optimise BlogBuilder in other ways.
- Roll up data rather than do live counts, such as comment, trackback and image counts
- Better indexes and improved query efficiency so that I don't have to cache the queries
- Profiling like crazy to find the hotspots. I recently got JProfiler working on a live instance of JBoss running BlogBuilder. It shed a lot of light on where our real bottlenecks are…and as usual, they are not where you expect.
My hopes when I was building BlogBuilder was that I could make everything dynamic and live for every user as this would provide a more personal and dynamic experience. Sadly this is not terribly efficient and I'm having to start to be a bit more pragmatic in where it is really neccessary to do live checks rather than static data.