mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
chore: Track db_slice table memory instantly (#3375)
We update table_memory upon each deletion and insertion of an element. Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
f73c7d0e42
commit
03b3f86aed
4 changed files with 31 additions and 7 deletions
|
@ -715,9 +715,10 @@ void EngineShard::CacheStats() {
|
|||
DbTable* table = db_slice.GetDBTable(i);
|
||||
if (table) {
|
||||
entries += table->prime.size();
|
||||
table_memory += (table->prime.mem_usage() + table->expire.mem_usage());
|
||||
table_memory += table->table_memory();
|
||||
}
|
||||
}
|
||||
DCHECK_EQ(table_memory, db_slice.table_memory());
|
||||
size_t obj_memory = table_memory <= used_mem ? used_mem - table_memory : 0;
|
||||
|
||||
size_t bytes_per_obj = entries > 0 ? obj_memory / entries : 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue