google / leveldb

LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values.
BSD 3-Clause "New" or "Revised" License
36.2k stars 7.79k forks source link

Why usage_ in LRUCache::Insert from cache.cc just add charge? #327

Open yandd opened 8 years ago

yandd commented 8 years ago
usage_ += charge;

I think this better:

usage_ += charge + (sizeof(LRUHandle)-1 + key.size());
cmumford commented 8 years ago

The "charge" used is the block size which already includes the key size if I'm reading the code correctly. It would arguable be more accurate to include the LRUHandle size, but as a percentage of overall cache size that is small. I'll confer with other developers and post a followup.