On 05/06/2015 07:39 AM, Alberto Garcia wrote: > The current algorithm to evict entries from the cache gives always > preference to those in the lowest positions. As the size of the cache > increases, the chances of the later elements of being removed decrease > exponentially. > > In a scenario with random I/O and lots of cache misses, entries in > positions 8 and higher are rarely (if ever) evicted. This can be seen > even with the default cache size, but with larger caches the problem > becomes more obvious. > > Using an LRU algorithm makes the chances of being removed from the > cache independent from the position. > > Signed-off-by: Alberto Garcia <be...@igalia.com> > --- > block/qcow2-cache.c | 31 +++++++++++++++---------------- > 1 file changed, 15 insertions(+), 16 deletions(-) >
> @@ -318,12 +315,10 @@ static int qcow2_cache_do_get(BlockDriverState *bs, > Qcow2Cache *c, > > /* Give the table some hits for the start so that it won't be replaced > * immediately. The number 32 is completely arbitrary. */ > - c->entries[i].cache_hits = 32; > c->entries[i].offset = offset; The comment is now dead. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature