[concurrency-interest] Memory sensitive memoization
Dhanji R. Prasanna
dhanji at gmail.com
Tue Jun 28 01:48:50 EDT 2011
On Tue, Jun 28, 2011 at 2:50 PM, Jed Wesley-Smith <
jwesleysmith at atlassian.com> wrote:
> We have found the hard way that using SoftReferences for what is
> essentially an application level concern (caching) is actually
> counter-productive for the most part. The problem being that they clear at
> the time when the application is under serious GC pressure, and there is no
> way to prioritise which ones get cleared. This means that caches start
> missing and expensive operations are performed right at the time when the
> application is under the most load, usually increasing the pressure on it.
Exactly, this was one of our most serious problems. Not all data LRU across
the same priority level. The problem with using SoftRefs for caching is that
it treats all memory as equal even across caches. There are also many many
other issues with softrefs, such as clearing overhead, clock timestamping,
the overhead of finalization (done in a single thread) and so on.
> I have heard several others (Cliff Click's "The JVM does what?" for
> instance, as well as various Google sources) express the same opinion, that
> SoftReferences are at best a somewhat illusory benefit.
Yep. There are others at Google who (reasonably) argue that efficient caches
can be built in Java but I was quite burned after deploying some of them in
production and argue against them often. I worked with a number of teams
(while at Google) managing very large Java deployments who had similar
conclusions to mine.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest