-
Notifications
You must be signed in to change notification settings - Fork 28.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-38178][SS] Correct the logic to measure the memory usage of RocksDB #35480
Conversation
5e094fc
to
b32a323
Compare
@@ -403,7 +404,7 @@ class RocksDB( | |||
RocksDBMetrics( | |||
numKeysOnLoadedVersion, | |||
numKeysOnWritingVersion, | |||
readerMemUsage + memTableMemUsage, | |||
readerMemUsage + memTableMemUsage + blockCacheUsage, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on the doc, do we also need rocksdb.block-cache-pinned-usage
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for @viirya 's comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on the doc, do we also need rocksdb.block-cache-pinned-usage?
No, I don't think so, and I actually write my conclusion in original ticket SPARK-38178:
BTW, as the "block-cache-pinned-usage" is included in "block-cache-usage", we don't need to include the pinned usage.
Let's take a look at the RocksDB implementation:
{DB::Properties::kBlockCacheUsage,
{false, nullptr, &InternalStats::HandleBlockCacheUsage, nullptr,
nullptr}},
{DB::Properties::kBlockCachePinnedUsage,
{false, nullptr, &InternalStats::HandleBlockCachePinnedUsage, nullptr,
nullptr}},
- And what will call for these two handle methods:
bool InternalStats::HandleBlockCacheUsage(uint64_t* value, DBImpl* /*db*/,
Version* /*version*/) {
Cache* block_cache;
bool ok = GetBlockCacheForStats(&block_cache);
if (!ok) {
return false;
}
*value = static_cast<uint64_t>(block_cache->GetUsage());
return true;
}
bool InternalStats::HandleBlockCachePinnedUsage(uint64_t* value, DBImpl* /*db*/,
Version* /*version*/) {
Cache* block_cache;
bool ok = GetBlockCacheForStats(&block_cache);
if (!ok) {
return false;
}
*value = static_cast<uint64_t>(block_cache->GetPinnedUsage());
return true;
}
- And then the implementation of these two getters:
size_t LRUCacheShard::GetUsage() const {
MutexLock l(&mutex_);
return usage_;
}
size_t LRUCacheShard::GetPinnedUsage() const {
MutexLock l(&mutex_);
assert(usage_ >= lru_usage_);
return usage_ - lru_usage_;
}
As you can see, the pinned usage is included in the block cache usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the detail, @Myasuka .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. Maybe it is good to put a sentence in the PR description to mention the fact that "block-cache-pinned-usage" is included in "block-cache-usage", so we don't need to include it separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viirya Thanks for your suggestions, I have already updated the PR description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like that is something we need to add to RocksDB memory usage.
cc @xuanyuanking too FYI |
…cksDB ### What changes were proposed in this pull request? Correct the logic to measure the memory usage of RocksDB to include the memory used by block cache. As "block-cache-pinned-usage" is included in "block-cache-usage", we don't need to sum the pinned usage separately. ### Why are the changes needed? Current reported metrics of RocksDB memory usage is not correct. ### Does this PR introduce _any_ user-facing change? NO ### How was this patch tested? The information could refer to https://github.com/facebook/rocksdb/wiki/Memory-usage-in-RocksDB Closes #35480 from Myasuka/rocksdb-mem-usage. Authored-by: Yun Tang <myasuka@live.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org> (cherry picked from commit 93a9464) Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Merged to master/3.2. Thank you, @Myasuka and all. |
Welcome to the Apache Spark community, @Myasuka . |
…cksDB ### What changes were proposed in this pull request? Correct the logic to measure the memory usage of RocksDB to include the memory used by block cache. As "block-cache-pinned-usage" is included in "block-cache-usage", we don't need to sum the pinned usage separately. ### Why are the changes needed? Current reported metrics of RocksDB memory usage is not correct. ### Does this PR introduce _any_ user-facing change? NO ### How was this patch tested? The information could refer to https://github.com/facebook/rocksdb/wiki/Memory-usage-in-RocksDB Closes apache#35480 from Myasuka/rocksdb-mem-usage. Authored-by: Yun Tang <myasuka@live.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org> (cherry picked from commit 93a9464) Signed-off-by: Dongjoon Hyun <dongjoon@apache.org> (cherry picked from commit 6646212)
What changes were proposed in this pull request?
Correct the logic to measure the memory usage of RocksDB to include the memory used by block cache.
As "block-cache-pinned-usage" is included in "block-cache-usage", we don't need to sum the pinned usage separately.
Why are the changes needed?
Current reported metrics of RocksDB memory usage is not correct.
Does this PR introduce any user-facing change?
NO
How was this patch tested?
The information could refer to https://github.com/facebook/rocksdb/wiki/Memory-usage-in-RocksDB