Caching in Leveldb

51 views
Skip to first unread message

f201...@hyderabad.bits-pilani.ac.in

unread,
Feb 21, 2018, 4:57:18 AM2/21/18
to leveldb
Hi, 
How is caching implemented in LevelDB? What are block_cache and table_cache structures used for? If my code does read of old data(stored in higher levels) frequently, will it be cached for quick reads or does the control go through all the levels to search for it?

Regards
Shikhar Bharadwaj

Daniel Murphy

unread,
Feb 21, 2018, 2:44:09 PM2/21/18
to lev...@googlegroups.com
The block cache is for block data, the table cache is for table metadata, which is a different file (I believe). The block cache is, by default, 8MB. It uses a sharded LRU eviction scheme and is multi-threaded. There are 16 random (based on hash) shards, and each shard is LRU. So it's combining random eviction (which is proven to be within 2* optimal or something like that), and LRU, which is pretty good for the compaction jobs. As far as I can tell it's a pretty good scheme.

See cache.h and cache.cc. The leveldb options should allow you to set a custom cache.

--
You received this message because you are subscribed to the Google Groups "leveldb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leveldb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages