Add node memory usage info to V3Stats (#4684)

This commit is contained in:
Geza Lore
2023-11-12 14:19:53 +00:00
committed by GitHub
parent 671a857560
commit bea82def10
5 changed files with 37 additions and 23 deletions
+15 -3
View File
@@ -104,8 +104,8 @@ public:
iterateConst(nodep);
// Shorthand
const auto addStat = [&](const std::string& name, double count) { //
V3Stats::addStat(stage, name, count);
const auto addStat = [&](const std::string& name, double count, unsigned precision = 0) {
V3Stats::addStat(stage, name, count, precision);
};
// Variable widths
@@ -124,13 +124,25 @@ public:
}
}
// Node types
// Node types (also total memory usage)
const auto typeName = [](int type) { return std::string{VNType{type}.ascii()}; };
const auto typeSize = [](int type) { return VNType{type}.typeInfo()->m_sizeof; };
size_t totalNodeMemoryUsage = 0;
for (int t = 0; t < VNType::_ENUM_END; ++t) {
if (const uint64_t count = m_counters.m_statTypeCount[t]) {
totalNodeMemoryUsage += count * typeSize(t);
addStat("Node count, " + typeName(t), count);
}
}
addStat("Node memory TOTAL (MiB)", totalNodeMemoryUsage >> 20);
// Node Memory usage
for (int t = 0; t < VNType::_ENUM_END; ++t) {
if (const uint64_t count = m_counters.m_statTypeCount[t]) {
const double share = 100.0 * count * typeSize(t) / totalNodeMemoryUsage;
addStat("Node memory share (%), " + typeName(t), share, 2);
}
}
// Expression combinations
for (int t1 = 0; t1 < VNType::_ENUM_END; ++t1) {