summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2016-10-06 11:55:21 -0500
committerMark Salyzyn2016-11-04 09:43:16 -0500
commit6d981af12023bcaf22bfa0612a85ae4580ecb971 (patch)
tree53142c0b299a8d0ec5eb0a612310c43b871d2ff1 /logd/LogStatistics.h
parentfc3e90689ecc452b3f0e05144df1580ad78d5d0d (diff)
downloadplatform-system-core-6d981af12023bcaf22bfa0612a85ae4580ecb971.tar.gz
platform-system-core-6d981af12023bcaf22bfa0612a85ae4580ecb971.tar.xz
platform-system-core-6d981af12023bcaf22bfa0612a85ae4580ecb971.zip
logd: report statistics memory overhead
Add in to the Total Overhead the amount of storage we are using to hold on to the statistics. Test: see that the Total Overhead accounts for about 100K Bug: 31942525 Change-Id: Ibe241c0bccc5a9df52395802338c8a7fc3b64104
Diffstat (limited to 'logd/LogStatistics.h')
-rw-r--r--logd/LogStatistics.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/logd/LogStatistics.h b/logd/LogStatistics.h
index bfaafa461..69fe91502 100644
--- a/logd/LogStatistics.h
+++ b/logd/LogStatistics.h
@@ -42,8 +42,30 @@ class LogHashtable {
42 42
43 std::unordered_map<TKey, TEntry> map; 43 std::unordered_map<TKey, TEntry> map;
44 44
45 size_t bucket_size() const {
46 size_t count = 0;
47 for (size_t idx = 0; idx < map.bucket_count(); ++idx) {
48 size_t bucket_size = map.bucket_size(idx);
49 if (bucket_size == 0) bucket_size = 1;
50 count += bucket_size;
51 }
52 float load_factor = map.max_load_factor();
53 if (load_factor < 1.0) return count;
54 return count * load_factor;
55 }
56
57 static const size_t unordered_map_per_entry_overhead = sizeof(void*);
58 static const size_t unordered_map_bucket_overhead = sizeof(void*);
59
45public: 60public:
46 61
62 // Estimate unordered_map memory usage.
63 size_t sizeOf() const {
64 return sizeof(*this) +
65 (map.size() * (sizeof(TEntry) + unordered_map_per_entry_overhead)) +
66 (bucket_size() * sizeof(size_t) + unordered_map_bucket_overhead);
67 }
68
47 typedef typename std::unordered_map<TKey, TEntry>::iterator iterator; 69 typedef typename std::unordered_map<TKey, TEntry>::iterator iterator;
48 typedef typename std::unordered_map<TKey, TEntry>::const_iterator const_iterator; 70 typedef typename std::unordered_map<TKey, TEntry>::const_iterator const_iterator;
49 71
@@ -155,6 +177,7 @@ public:
155 } 177 }
156 return output; 178 return output;
157 } 179 }
180
158}; 181};
159 182
160namespace EntryBaseConstants { 183namespace EntryBaseConstants {
@@ -472,7 +495,26 @@ class LogStatistics {
472 // security tag list 495 // security tag list
473 tagTable_t securityTagTable; 496 tagTable_t securityTagTable;
474 497
498 size_t sizeOf() const {
499 size_t size = sizeof(*this) + pidTable.sizeOf() + tidTable.sizeOf() +
500 tagTable.sizeOf() + securityTagTable.sizeOf();
501 for(auto it : pidTable) {
502 const char* name = it.second.getName();
503 if (name) size += strlen(name) + 1;
504 }
505 for(auto it : tidTable) {
506 const char* name = it.second.getName();
507 if (name) size += strlen(name) + 1;
508 }
509 log_id_for_each(id) {
510 size += uidTable[id].sizeOf();
511 size += pidSystemTable[id].sizeOf();
512 }
513 return size;
514 }
515
475public: 516public:
517
476 LogStatistics(); 518 LogStatistics();
477 519
478 void enableStatistics() { enable = true; } 520 void enableStatistics() { enable = true; }