fix(server): remove double decrement of obj_memory_usage. (#406)

Also, add timing stats to malloc-stats command.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2022-10-19 14:32:03 +03:00 committed by GitHub
parent b5cbed79d7
commit ab72ff797c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View file

@ -419,8 +419,6 @@ tuple<PrimeIterator, ExpireIterator, bool> DbSlice::AddOrFind2(const Context& cn
// Keep the entry but reset the object.
size_t value_heap_size = existing->second.MallocUsed();
db.stats.obj_memory_usage -= value_heap_size;
if (existing->second.ObjType() == OBJ_STRING)
db.stats.obj_memory_usage -= value_heap_size;
existing->second.Reset();
events_.expired_keys++;

View file

@ -57,6 +57,8 @@ void MemoryCmd::Run(CmdArgList args) {
string MemoryCmd::MallocStats() {
string str;
uint64_t start = absl::GetCurrentTimeNanos();
absl::StrAppend(&str, "___ Begin mimalloc statistics ___\n");
mi_stats_print_out(MiStatsCallback, &str);
@ -73,7 +75,8 @@ string MemoryCmd::MallocStats() {
get<2>(k_v.first), " ", get<3>(k_v.first), "\n");
}
absl::StrAppend(&str, "--- End mimalloc statistics ---\n");
uint64_t delta = (absl::GetCurrentTimeNanos() - start) / 1000;
absl::StrAppend(&str, "--- End mimalloc statistics, took ", delta, "us ---\n");
return str;
}