Hi,
I filed
Chromium bug 1010925 to start a discussion on whether we could add a LRU Cache to WTF to provide a reliable LRU Cache blink wide, based on Blink container types and Blink's hashing.
Various places in Blink implement something similar, some have size boundaries, some don't and the implementations differ in sophistication, for example:
and possibly more.
The level of testing for these individually is in my opinion relatively sparse.
In //base, there is a MRUCache which does something very similar but can't be used in Blink as is because it uses STL container types internally.
I started working on this or proposing this, because I need to add a cache to avoid out of process calls for font fallback in a particular scenario (
issue 1005234).
I was faced with the situation of writing another task specific cache implementation or proposing a generic one.
In my opinion, it'd be useful to have this at the WTF level, if we can design it in a way that we could perhaps make one or two of the existing LRU-like implementation use it with benefit. Several clients could benefit from optimizations to the cache and less time is wasted rewriting such cache logic when it's needed multiple times. Also, it could become easier to reason about such caches' memory consumption behavior, as we don't have to analyse each different implementation individually.
haraken@ already had some comments on the bug and suggested to move the discussion here, so I'd leave it up to you, Kentaro, to repeat your comments here.
Thanks very much for considering adding a LRU Cache,
Dominik