From b0672290e320113f4b6d8fc6bb2d1e0afe493c5c Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Thu, 6 Oct 2016 10:09:24 -0700 Subject: [PATCH] logd: report last prune memory overhead An estimate based on chatty impact for all known pids, uids and tags and per log id if applicable, calculate the maximum last pruned watermark iterator map usage and add to the Total Overhead. Test: Confirm that the Total Overhead change is negligable. Bug: 31942525 Change-Id: Icd2e9bc0747c3376ca0e9c90aa110c103529d98f --- logd/LogStatistics.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/logd/LogStatistics.h b/logd/LogStatistics.h index 69fe91502..1f598af8a 100644 --- a/logd/LogStatistics.h +++ b/logd/LogStatistics.h @@ -59,10 +59,12 @@ class LogHashtable { public: + size_t size() const { return map.size(); } + // Estimate unordered_map memory usage. size_t sizeOf() const { return sizeof(*this) + - (map.size() * (sizeof(TEntry) + unordered_map_per_entry_overhead)) + + (size() * (sizeof(TEntry) + unordered_map_per_entry_overhead)) + (bucket_size() * sizeof(size_t) + unordered_map_bucket_overhead); } @@ -497,7 +499,9 @@ class LogStatistics { size_t sizeOf() const { size_t size = sizeof(*this) + pidTable.sizeOf() + tidTable.sizeOf() + - tagTable.sizeOf() + securityTagTable.sizeOf(); + tagTable.sizeOf() + securityTagTable.sizeOf() + + (pidTable.size() * sizeof(pidTable_t::iterator)) + + (tagTable.size() * sizeof(tagTable_t::iterator)); for(auto it : pidTable) { const char* name = it.second.getName(); if (name) size += strlen(name) + 1; @@ -508,7 +512,9 @@ class LogStatistics { } log_id_for_each(id) { size += uidTable[id].sizeOf(); + size += uidTable[id].size() * sizeof(uidTable_t::iterator); size += pidSystemTable[id].sizeOf(); + size += pidSystemTable[id].size() * sizeof(pidSystemTable_t::iterator); } return size; }