Add node memory usage info to V3Stats (#4684)
This commit is contained in:
parent
671a857560
commit
bea82def10
|
|
@ -107,6 +107,7 @@ struct VNTypeInfo {
|
|||
OP_OPTIONAL,
|
||||
} m_opType[4];
|
||||
const char* m_opNamep[4];
|
||||
size_t m_sizeof;
|
||||
};
|
||||
|
||||
class VNType final {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -68,7 +68,8 @@ public:
|
|||
class V3Statistic final {
|
||||
// A statistical entry we want published into the database
|
||||
const string m_name; ///< Name of this statistic
|
||||
double m_count; ///< Count of occurrences/ value
|
||||
double m_value; ///< Value of statistic (count, ratio, etc.)
|
||||
unsigned m_precision; ///< Precision to print with (number of fractional digits)
|
||||
const string m_stage; ///< Runtime stage
|
||||
const bool m_sumit; ///< Do summation of similar stats
|
||||
const bool m_perf; ///< Performance section
|
||||
|
|
@ -77,20 +78,22 @@ public:
|
|||
// METHODS
|
||||
string stage() const VL_MT_SAFE { return m_stage; }
|
||||
string name() const VL_MT_SAFE { return m_name; }
|
||||
double count() const VL_MT_SAFE { return m_count; }
|
||||
double value() const VL_MT_SAFE { return m_value; }
|
||||
unsigned precision() const VL_MT_SAFE { return m_precision; }
|
||||
bool sumit() const VL_MT_SAFE { return m_sumit; }
|
||||
bool perf() const VL_MT_SAFE { return m_perf; }
|
||||
bool printit() const VL_MT_SAFE { return m_printit; }
|
||||
virtual void dump(std::ofstream& os) const VL_MT_SAFE;
|
||||
void combineWith(V3Statistic* otherp) {
|
||||
m_count += otherp->count();
|
||||
m_value += otherp->value();
|
||||
otherp->m_printit = false;
|
||||
}
|
||||
// CONSTRUCTORS
|
||||
V3Statistic(const string& stage, const string& name, double count, bool sumit = false,
|
||||
bool perf = false)
|
||||
V3Statistic(const string& stage, const string& name, double value, unsigned precision,
|
||||
bool sumit = false, bool perf = false)
|
||||
: m_name{name}
|
||||
, m_count{count}
|
||||
, m_value{value}
|
||||
, m_precision{precision}
|
||||
, m_stage{stage}
|
||||
, m_sumit{sumit}
|
||||
, m_perf{perf} {}
|
||||
|
|
@ -102,17 +105,18 @@ public:
|
|||
class V3Stats final {
|
||||
public:
|
||||
static void addStat(const V3Statistic&);
|
||||
static void addStat(const string& stage, const string& name, double count) {
|
||||
addStat(V3Statistic{stage, name, count});
|
||||
static void addStat(const string& stage, const string& name, double value,
|
||||
unsigned precision = 0) {
|
||||
addStat(V3Statistic{stage, name, value, precision});
|
||||
}
|
||||
static void addStat(const string& name, double count) {
|
||||
addStat(V3Statistic{"*", name, count});
|
||||
static void addStat(const string& name, double value, unsigned precision = 0) {
|
||||
addStat(V3Statistic{"*", name, value, precision});
|
||||
}
|
||||
static void addStatSum(const string& name, double count) {
|
||||
addStat(V3Statistic{"*", name, count, true});
|
||||
addStat(V3Statistic{"*", name, count, 0, true});
|
||||
}
|
||||
static void addStatPerf(const string& name, double count) {
|
||||
addStat(V3Statistic{"*", name, count, true, true});
|
||||
static void addStatPerf(const string& name, double value) {
|
||||
addStat(V3Statistic{"*", name, value, 6, true, true});
|
||||
}
|
||||
/// Called each stage
|
||||
static void statsStage(const string& name);
|
||||
|
|
|
|||
|
|
@ -181,11 +181,8 @@ StatsReport::StatColl StatsReport::s_allStats;
|
|||
// V3Statstic class
|
||||
|
||||
void V3Statistic::dump(std::ofstream& os) const {
|
||||
if (perf()) {
|
||||
os << " " << std::right << std::fixed << std::setprecision(6) << std::setw(9) << count();
|
||||
} else {
|
||||
os << " " << std::right << std::fixed << std::setprecision(0) << std::setw(9) << count();
|
||||
}
|
||||
os << " " << std::right << std::fixed << std::setprecision(precision()) << std::setw(9)
|
||||
<< value();
|
||||
}
|
||||
|
||||
//######################################################################
|
||||
|
|
|
|||
|
|
@ -933,8 +933,8 @@ def write_ast_type_info(filename):
|
|||
['VNTypeInfo::{0}'.format(s) for s in opTypeList])
|
||||
opNameStr = ', '.join(['"{0}"'.format(s) for s in opNameList])
|
||||
fh.write(
|
||||
' {{ "Ast{name}", {{{opTypeStr}}}, {{{opNameStr}}} }},\n'.
|
||||
format(
|
||||
' {{ "Ast{name}", {{{opTypeStr}}}, {{{opNameStr}}}, sizeof(Ast{name}) }},\n'
|
||||
.format(
|
||||
name=node.name,
|
||||
opTypeStr=opTypeStr,
|
||||
opNameStr=opNameStr,
|
||||
|
|
|
|||
Loading…
Reference in New Issue