From ee80fb4b4ae8f26ee44f7064487d609b5d2dfb14 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Fri, 17 Oct 2014 09:26:27 -0700 Subject: [PATCH] Total memtables size counter Summary: Added one new counter for GetProperty Test Plan: Not sure if needs a test case. compiles Reviewers: sdong Reviewed By: sdong Subscribers: leveldb Differential Revision: https://reviews.facebook.net/D25023 --- db/internal_stats.cc | 11 +++++++++-- db/internal_stats.h | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/db/internal_stats.cc b/db/internal_stats.cc index 3f60d72ce..aa3b3c850 100644 --- a/db/internal_stats.cc +++ b/db/internal_stats.cc @@ -133,6 +133,8 @@ DBPropertyType GetPropertyType(const Slice& property, bool* is_int_property, return kBackgroundErrors; } else if (in == "cur-size-active-mem-table") { return kCurSizeActiveMemTable; + } else if (in == "cur-size-all-mem-tables") { + return kCurSizeAllMemTables; } else if (in == "num-entries-active-mem-table") { return kNumEntriesInMutableMemtable; } else if (in == "num-entries-imm-mem-tables") { @@ -250,12 +252,17 @@ bool InternalStats::GetIntProperty(DBPropertyType property_type, // Current size of the active memtable *value = cfd_->mem()->ApproximateMemoryUsage(); return true; + case kCurSizeAllMemTables: + // Current size of the active memtable + immutable memtables + *value = cfd_->mem()->ApproximateMemoryUsage() + + cfd_->imm()->ApproximateMemoryUsage(); + return true; case kNumEntriesInMutableMemtable: - // Current size of the active memtable + // Current number of entires in the active memtable *value = cfd_->mem()->GetNumEntries(); return true; case kNumEntriesInImmutableMemtable: - // Current size of the active memtable + // Current number of entries in the immutable memtables *value = cfd_->imm()->current()->GetTotalNumEntries(); return true; case kEstimatedNumKeys: diff --git a/db/internal_stats.h b/db/internal_stats.h index 18d67de5c..4d12a2512 100644 --- a/db/internal_stats.h +++ b/db/internal_stats.h @@ -36,6 +36,8 @@ enum DBPropertyType : uint32_t { kCompactionPending, // Return 1 if a compaction is pending. Otherwise 0. kBackgroundErrors, // Return accumulated background errors encountered. kCurSizeActiveMemTable, // Return current size of the active memtable + kCurSizeAllMemTables, // Return current size of all (active + immutable) + // memtables kNumEntriesInMutableMemtable, // Return number of entries in the mutable // memtable. kNumEntriesInImmutableMemtable, // Return sum of number of entries in all