Skip to content

Commit

Permalink
Improve the precision of row entry charge in row_cache (facebook#9337)
Browse files Browse the repository at this point in the history
Summary:
- For entry charge, we should only calculate the value size instead of including key size in LRUCache
- The capacity of string could show the memory usage precisely

Pull Request resolved: facebook#9337

Reviewed By: ajkr

Differential Revision: D36219855

fbshipit-source-id: 393e48ca419d230dc552ae62dd0eb1cc9f45961d
  • Loading branch information
ShooterIT authored and facebook-github-bot committed May 9, 2022
1 parent 39b6c57 commit 89571b3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions db/table_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,7 @@ Status TableCache::Get(
#ifndef ROCKSDB_LITE
// Put the replay log in row cache only if something was found.
if (!done && s.ok() && row_cache_entry && !row_cache_entry->empty()) {
size_t charge =
row_cache_key.Size() + row_cache_entry->size() + sizeof(std::string);
size_t charge = row_cache_entry->capacity() + sizeof(std::string);
void* row_ptr = new std::string(std::move(*row_cache_entry));
// If row cache is full, it's OK to continue.
ioptions_.row_cache
Expand Down Expand Up @@ -592,8 +591,7 @@ Status TableCache::MultiGet(
user_key.size());
// Put the replay log in row cache only if something was found.
if (s.ok() && !row_cache_entry.empty()) {
size_t charge =
row_cache_key.Size() + row_cache_entry.size() + sizeof(std::string);
size_t charge = row_cache_entry.capacity() + sizeof(std::string);
void* row_ptr = new std::string(std::move(row_cache_entry));
// If row cache is full, it's OK.
ioptions_.row_cache
Expand Down

0 comments on commit 89571b3

Please sign in to comment.