mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
fix: Fix bugs around rdb save and improve memory accounting (#495)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
1236f92381
commit
c2294e1298
4 changed files with 24 additions and 16 deletions
|
@ -52,7 +52,7 @@ void MemoryCmd::Run(CmdArgList args) {
|
|||
return (*cntx_)->SendError(kInvalidIntErr);
|
||||
}
|
||||
tid = tid % shard_set->pool()->size();
|
||||
string res = shard_set->pool()->at(tid)->AwaitBrief([this] { return MallocStats(); });
|
||||
string res = shard_set->pool()->at(tid)->AwaitBrief([&] { return MallocStats(tid); });
|
||||
|
||||
return (*cntx_)->SendBulkString(res);
|
||||
}
|
||||
|
@ -61,28 +61,33 @@ void MemoryCmd::Run(CmdArgList args) {
|
|||
return (*cntx_)->SendError(err, kSyntaxErrType);
|
||||
}
|
||||
|
||||
string MemoryCmd::MallocStats() {
|
||||
string MemoryCmd::MallocStats(unsigned tid) {
|
||||
string str;
|
||||
|
||||
uint64_t start = absl::GetCurrentTimeNanos();
|
||||
absl::StrAppend(&str, "___ Begin mimalloc statistics ___\n");
|
||||
mi_stats_print_out(MiStatsCallback, &str);
|
||||
|
||||
absl::StrAppend(&str, "\nArena statistics from a single thread:\n");
|
||||
absl::StrAppend(&str, "\nArena statistics from thread:", tid, "\n");
|
||||
absl::StrAppend(&str, "Count BlockSize Reserved Committed Used\n");
|
||||
|
||||
mi_heap_t* data_heap = ServerState::tlocal()->data_heap();
|
||||
BlockMap block_map;
|
||||
|
||||
mi_heap_visit_blocks(data_heap, false /* visit all blocks*/, MiArenaVisit, &block_map);
|
||||
|
||||
uint64_t reserved = 0, committed = 0, used = 0;
|
||||
for (const auto& k_v : block_map) {
|
||||
absl::StrAppend(&str, k_v.second, " ", get<0>(k_v.first), " ", get<1>(k_v.first), " ",
|
||||
get<2>(k_v.first), " ", get<3>(k_v.first), "\n");
|
||||
reserved += k_v.second * get<1>(k_v.first);
|
||||
committed += k_v.second * get<2>(k_v.first);
|
||||
used += k_v.second * get<3>(k_v.first);
|
||||
}
|
||||
|
||||
uint64_t delta = (absl::GetCurrentTimeNanos() - start) / 1000;
|
||||
absl::StrAppend(&str, "--- End mimalloc statistics, took ", delta, "us ---\n");
|
||||
absl::StrAppend(&str, "total reserved: ", reserved, ", comitted: ", committed, ", used: ", used,
|
||||
"\n");
|
||||
|
||||
return str;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue