]> git.proxmox.com Git - mirror_qemu.git/commit
qcow2: use an LRU algorithm to replace entries from the L2 cache
authorAlberto Garcia <berto@igalia.com>
Mon, 11 May 2015 12:54:55 +0000 (15:54 +0300)
committerKevin Wolf <kwolf@redhat.com>
Fri, 22 May 2015 15:08:01 +0000 (17:08 +0200)
commit2693310eccccf8351678ddd6f3b050163e51dba0
tree22a345f37c5c2501977b3f115b3b8cd91aa7e219
parentbaf07d60f5c5d5d0f0c9e844cde75691f1ceb3d1
qcow2: use an LRU algorithm to replace entries from the L2 cache

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 <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/qcow2-cache.c