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
This commit is contained in:
Igor Canadi 2014-10-17 09:26:27 -07:00
parent c12f571d31
commit ee80fb4b4a
2 changed files with 11 additions and 2 deletions

View File

@ -133,6 +133,8 @@ DBPropertyType GetPropertyType(const Slice& property, bool* is_int_property,
return kBackgroundErrors; return kBackgroundErrors;
} else if (in == "cur-size-active-mem-table") { } else if (in == "cur-size-active-mem-table") {
return kCurSizeActiveMemTable; return kCurSizeActiveMemTable;
} else if (in == "cur-size-all-mem-tables") {
return kCurSizeAllMemTables;
} else if (in == "num-entries-active-mem-table") { } else if (in == "num-entries-active-mem-table") {
return kNumEntriesInMutableMemtable; return kNumEntriesInMutableMemtable;
} else if (in == "num-entries-imm-mem-tables") { } else if (in == "num-entries-imm-mem-tables") {
@ -250,12 +252,17 @@ bool InternalStats::GetIntProperty(DBPropertyType property_type,
// Current size of the active memtable // Current size of the active memtable
*value = cfd_->mem()->ApproximateMemoryUsage(); *value = cfd_->mem()->ApproximateMemoryUsage();
return true; return true;
case kCurSizeAllMemTables:
// Current size of the active memtable + immutable memtables
*value = cfd_->mem()->ApproximateMemoryUsage() +
cfd_->imm()->ApproximateMemoryUsage();
return true;
case kNumEntriesInMutableMemtable: case kNumEntriesInMutableMemtable:
// Current size of the active memtable // Current number of entires in the active memtable
*value = cfd_->mem()->GetNumEntries(); *value = cfd_->mem()->GetNumEntries();
return true; return true;
case kNumEntriesInImmutableMemtable: case kNumEntriesInImmutableMemtable:
// Current size of the active memtable // Current number of entries in the immutable memtables
*value = cfd_->imm()->current()->GetTotalNumEntries(); *value = cfd_->imm()->current()->GetTotalNumEntries();
return true; return true;
case kEstimatedNumKeys: case kEstimatedNumKeys:

View File

@ -36,6 +36,8 @@ enum DBPropertyType : uint32_t {
kCompactionPending, // Return 1 if a compaction is pending. Otherwise 0. kCompactionPending, // Return 1 if a compaction is pending. Otherwise 0.
kBackgroundErrors, // Return accumulated background errors encountered. kBackgroundErrors, // Return accumulated background errors encountered.
kCurSizeActiveMemTable, // Return current size of the active memtable 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 kNumEntriesInMutableMemtable, // Return number of entries in the mutable
// memtable. // memtable.
kNumEntriesInImmutableMemtable, // Return sum of number of entries in all kNumEntriesInImmutableMemtable, // Return sum of number of entries in all