Improve the precision of row entry charge in row_cache (#9337)
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: https://github.com/facebook/rocksdb/pull/9337 Reviewed By: ajkr Differential Revision: D36219855 fbshipit-source-id: 393e48ca419d230dc552ae62dd0eb1cc9f45961d
This commit is contained in:
parent
39b6c5791a
commit
89571b30e5
|
@ -468,8 +468,7 @@ Status TableCache::Get(
|
||||||
#ifndef ROCKSDB_LITE
|
#ifndef ROCKSDB_LITE
|
||||||
// Put the replay log in row cache only if something was found.
|
// Put the replay log in row cache only if something was found.
|
||||||
if (!done && s.ok() && row_cache_entry && !row_cache_entry->empty()) {
|
if (!done && s.ok() && row_cache_entry && !row_cache_entry->empty()) {
|
||||||
size_t charge =
|
size_t charge = row_cache_entry->capacity() + sizeof(std::string);
|
||||||
row_cache_key.Size() + row_cache_entry->size() + sizeof(std::string);
|
|
||||||
void* row_ptr = new std::string(std::move(*row_cache_entry));
|
void* row_ptr = new std::string(std::move(*row_cache_entry));
|
||||||
// If row cache is full, it's OK to continue.
|
// If row cache is full, it's OK to continue.
|
||||||
ioptions_.row_cache
|
ioptions_.row_cache
|
||||||
|
@ -592,8 +591,7 @@ Status TableCache::MultiGet(
|
||||||
user_key.size());
|
user_key.size());
|
||||||
// Put the replay log in row cache only if something was found.
|
// Put the replay log in row cache only if something was found.
|
||||||
if (s.ok() && !row_cache_entry.empty()) {
|
if (s.ok() && !row_cache_entry.empty()) {
|
||||||
size_t charge =
|
size_t charge = row_cache_entry.capacity() + sizeof(std::string);
|
||||||
row_cache_key.Size() + row_cache_entry.size() + sizeof(std::string);
|
|
||||||
void* row_ptr = new std::string(std::move(row_cache_entry));
|
void* row_ptr = new std::string(std::move(row_cache_entry));
|
||||||
// If row cache is full, it's OK.
|
// If row cache is full, it's OK.
|
||||||
ioptions_.row_cache
|
ioptions_.row_cache
|
||||||
|
|
Loading…
Reference in New Issue
Block a user