Commit 030562f6 authored by Alessio Netti's avatar Alessio Netti
Browse files

ProcFS: improved HT aggregation

- Now operates identically to PerfEvents: only the CPUs in the specified
configuration set are aggregated
parent d7c31f24
......@@ -394,7 +394,7 @@ bool ProcstatParser::_readNames(std::map<std::string, ProcfsSBPtr> *sensorMap, s
effCPU = (_htAggr && currCPU >= 0) ? currCPU % _htVal : currCPU;
colCtr = 0;
parsedCols = 0;
if (currCPU == -1 || cpuSet == NULL || cpuSet->empty() || cpuSet->find(effCPU) != cpuSet->end()) {
if (currCPU == -1 || cpuSet == NULL || cpuSet->empty() || cpuSet->find(currCPU) != cpuSet->end()) {
// The number of CPU cores in the system is inferred from the maximum CPU ID found while parsing
if (currCPU >= (int)_numCPUs)
_numCPUs = currCPU + 1;
......@@ -402,7 +402,7 @@ bool ProcstatParser::_readNames(std::map<std::string, ProcfsSBPtr> *sensorMap, s
std::string cpuName(lineToken);
while ((lineToken = strtok_r(_stringBuffer, LINE_SEP, &savePtr)) != NULL && colCtr < DEFAULTMETRICS) {
if (_skipColumn[colCtr] == 1 || (_skipColumn[colCtr] == 2 && currCPU == -1)) {
if (currCPU == -1 || effCPU == currCPU) {
if (currCPU == -1 || htMap.find(effCPU) == htMap.end()) {
if (sensorMap != NULL && !sensorMap->empty())
s = std::make_shared<ProcfsSensorBase>(*sensorMap->find(DEFAULT_NAMES[colCtr])->second);
else {
......@@ -458,14 +458,14 @@ bool ProcstatParser::_readNames(std::map<std::string, ProcfsSBPtr> *sensorMap, s
}
_lines.push_back(line);
// Mapping the current CPU id to its first sensor entry in the vector
if (line.cpuID >= 0)
htMap.insert(std::make_pair(currCPU, line));
if (line.cpuID >= 0 && htMap.find(effCPU) == htMap.end())
htMap.insert(std::make_pair(effCPU, line));
}
_numMetrics = _sensors->size();
// Adjusting the destinations in case of hyperthreading aggregation
if (_htAggr)
for (auto &l : _lines)
if (!l.skip && l.cpuID >= 0 && l.cpuID % _htVal != l.cpuID)
if (!l.skip && l.cpuID >= 0 && htMap.find(l.cpuID) == htMap.end() && htMap.find(l.cpuID % _htVal) != htMap.end())
l.dest = htMap[l.cpuID % _htVal].dest;
htMap.clear();
}
......@@ -658,12 +658,16 @@ bool SARParser::_readMetrics() {
}
// Computing percentages in SAR style
for (auto &l : _lines)
if (!l.skip && l.multi && (!_htAggr || l.cpuID < _htVal)) {
for (colCtr = 0; colCtr < (unsigned)l.columns; colCtr++)
_readings->at(l.dest + colCtr).value = _readings->at(l.dest + colCtr).value * _scalingFactor / _accumulators[l.cpuID + 1];
_accumulators[l.cpuID + 1] = 1;
short effCpu=0;
for (auto &l : _lines) {
effCpu = (_htAggr && l.cpuID >= 0) ? l.cpuID % _htVal : l.cpuID;
// Percentages are computed only once per hyperthreading "bin"
if (!l.skip && l.multi && _accumulators[effCpu + 1] != 1) {
for (colCtr = 0; colCtr < (unsigned) l.columns; colCtr++)
_readings->at(l.dest + colCtr).value = _readings->at(l.dest + colCtr).value * _scalingFactor / _accumulators[effCpu + 1];
_accumulators[effCpu + 1] = 1;
}
}
// Error: the number of read metrics does not match the one at initialization, file must have changed
if (ctr != _numInternalMetrics)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment