Alexey Maykov ee95cae9a4 Modifed the LRU cache eviction code so that it doesn't evict blocks which have exteranl references
Summary:
Currently, blocks which have more than one reference (ie referenced by something other than cache itself) are evicted from cache. This doesn't make much sense:
- blocks are still in RAM, so the RAM usage reported by the cache is incorrect
- if the same block is needed by another iterator, it will be loaded and decompressed again

This diff changes the reference counting scheme a bit. Previously, if the cache contained the block, this was accounted for in its refcount. After this change, the refcount is only used to track external references. There is a boolean flag which indicates whether or not the block is contained in the cache.
This diff also changes how LRU list is used. Previously, both hashtable and the LRU list contained all blocks. After this change, the LRU list contains blocks with the refcount==0, ie those which can be evicted from the cache.

Note that this change still allows for cache to grow beyond its capacity. This happens when all blocks are pinned (ie refcount>0). This is consistent with the current behavior. The cache's insert function never fails. I spent lots of time trying to make table_reader and other places work with the insert which might failed. It turned out to be pretty hard. It might really destabilize some customers, so finally, I decided against doing this.

table_cache_remove_scan_count_limit option will be unneeded after this change, but I will remove it in the following diff, if this one gets approved

Test Plan: Ran tests, made sure they pass

Reviewers: sdong, ljin

Differential Revision: https://reviews.facebook.net/D25503
2014-12-10 22:28:53 -08:00
..
2014-11-21 14:11:40 -08:00
2014-10-31 11:59:54 -07:00
2014-11-07 15:04:30 -08:00
2014-08-19 09:52:54 -04:00
2014-08-19 06:48:21 -07:00
2014-12-09 10:22:07 -08:00
2014-11-14 11:38:26 -08:00
2014-11-14 11:38:26 -08:00
2014-11-20 10:49:32 -08:00
2014-08-28 12:46:05 -04:00
2014-08-28 12:46:05 -04:00
2014-09-21 22:20:00 +08:00
2014-11-14 11:38:26 -08:00
2014-11-14 11:38:26 -08:00
2014-07-25 15:17:06 -07:00
2014-09-05 14:14:37 +08:00
2014-07-28 12:10:49 -07:00
2014-07-28 12:22:37 -07:00
2014-11-21 11:05:28 -05:00
2014-04-17 14:29:28 -07:00
2014-09-08 22:24:40 -07:00
2014-10-31 11:59:54 -07:00
2014-05-01 14:09:32 -04:00
2014-05-01 14:09:32 -04:00