Commit 13d467df authored by Carla Guillen Carias's avatar Carla Guillen Carias
Browse files

small bugfix and adding cassandra as a backend with scaling factor

parent d7fe4402
...@@ -99,7 +99,16 @@ void PerSystSqlConfigurator::operatorAttributes(PerSystSqlOperator& op, CFG_VAL ...@@ -99,7 +99,16 @@ void PerSystSqlConfigurator::operatorAttributes(PerSystSqlOperator& op, CFG_VAL
} else if (boost::iequals(val.first, "severity_max_memory")){ } else if (boost::iequals(val.first, "severity_max_memory")){
auto max_memory = std::stof(val.second.data()); auto max_memory = std::stof(val.second.data());
op.setSeverityMaxMemory(max_memory); op.setSeverityMaxMemory(max_memory);
} } else if (boost::iequals(val.first, "backend")) {
if(val.second.data() == "cassandra") {
op.setBackend(PerSystSqlOperator::CASSANDRA);
} else if(val.second.data() == "mariadb") {
op.setBackend(PerSystSqlOperator::MARIADB);
}
} else if(boost::iequals(val.first, "scaling_factor")){
auto scaling_factor = std::stoull(val.second.data());
op.setScalingFactor(scaling_factor);
}
} }
} }
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
PerSystSqlOperator::PerSystSqlOperator(const std::string& name) : PerSystSqlOperator::PerSystSqlOperator(const std::string& name) :
OperatorTemplate(name), JobOperatorTemplate(name), _number_of_even_quantiles(0), OperatorTemplate(name), JobOperatorTemplate(name), _number_of_even_quantiles(0),
_severity_formula(NOFORMULA), _severity_threshold(0), _severity_exponent(0), _severity_formula(NOFORMULA), _severity_threshold(0), _severity_exponent(0),
_severity_max_memory(0), _go_back_ns(0) { _severity_max_memory(0), _go_back_ns(0), _backend(DEFAULT), _scaling_factor(1) {
} }
PerSystSqlOperator::~PerSystSqlOperator() { PerSystSqlOperator::~PerSystSqlOperator() {
...@@ -68,7 +68,7 @@ void PerSystSqlOperator::compute(U_Ptr unit, qeJobData& jobData) { ...@@ -68,7 +68,7 @@ void PerSystSqlOperator::compute(U_Ptr unit, qeJobData& jobData) {
// Since we do not clear the internal buffer, all sensor readings will be accumulated in the same vector // Since we do not clear the internal buffer, all sensor readings will be accumulated in the same vector
for(const auto& in : subUnit->getInputs()) { for(const auto& in : subUnit->getInputs()) {
if(!_queryEngine.querySensor(in->getName(), my_timestamp, my_timestamp, _buffer, false)){ if(!_queryEngine.querySensor(in->getName(), my_timestamp, my_timestamp, _buffer, false)){
LOG(debug) << "Job Operator " << _name << " cannot read from sensor " << in->getName() << "!"; LOG(debug) << "PerSystSql Operator " << _name << " cannot read from sensor " << in->getName() << "!";
return; return;
} }
} }
...@@ -90,23 +90,39 @@ void PerSystSqlOperator::compute_internal(U_Ptr& unit, vector<reading_t>& buffer ...@@ -90,23 +90,39 @@ void PerSystSqlOperator::compute_internal(U_Ptr& unit, vector<reading_t>& buffer
if(op!=AggregatorSensorBase::QTL) { if(op!=AggregatorSensorBase::QTL) {
switch (op) { switch (op) {
case AggregatorSensorBase::SUM: case AggregatorSensorBase::SUM:
reading.value = punDoubleToLL(std::accumulate(douBuffer.begin(), douBuffer.end(), 0.0)); if(_backend == CASSANDRA){
reading.value = std::accumulate(douBuffer.begin(), douBuffer.end(), 0.0) * _scaling_factor;
} else {
reading.value = punDoubleToLL(std::accumulate(douBuffer.begin(), douBuffer.end(), 0.0));
}
break; break;
case AggregatorSensorBase::AVG: case AggregatorSensorBase::AVG:
reading.value = punDoubleToLL(std::accumulate(douBuffer.begin(), douBuffer.end(), 0.0)/douBuffer.size()); if(_backend == CASSANDRA){
reading.value = std::accumulate(douBuffer.begin(), douBuffer.end(), 0.0)/douBuffer.size() * _scaling_factor;
} else {
reading.value = punDoubleToLL(std::accumulate(douBuffer.begin(), douBuffer.end(), 0.0)/douBuffer.size());
}
break; break;
case AggregatorSensorBase::OBS: case AggregatorSensorBase::OBS:
reading.value = computeObs(buffer); reading.value = computeObs(buffer);
break; break;
case AggregatorSensorBase::AVG_SEV: case AggregatorSensorBase::AVG_SEV:
reading.value = punDoubleToLL(computeSeverityAverage(douBuffer)); if(_backend == CASSANDRA) {
reading.value = computeSeverityAverage(douBuffer)* _scaling_factor;
} else {
reading.value = punDoubleToLL(computeSeverityAverage(douBuffer));
}
break; break;
default: default:
LOG(warning) << _name << ": Operation " << op << " not supported!"; LOG(warning) << _name << ": Operation " << op << " not supported!";
reading.value = 0; reading.value = 0;
break; break;
} }
out->storeReading(reading); if(_backend == CASSANDRA){
out->storeReading(reading);
} else {
//ToDo
}
} else { } else {
_quantileSensors.push_back(out); _quantileSensors.push_back(out);
} }
......
...@@ -43,6 +43,13 @@ public: ...@@ -43,6 +43,13 @@ public:
FORMULA3 = 3, FORMULA3 = 3,
MEMORY_FORMULA = 4, MEMORY_FORMULA = 4,
}; };
enum Backend_t {
CASSANDRA = 0,
MARIADB = 1,
DEFAULT = MARIADB
};
public: public:
PerSystSqlOperator(const std::string& name); PerSystSqlOperator(const std::string& name);
virtual ~PerSystSqlOperator(); virtual ~PerSystSqlOperator();
...@@ -80,6 +87,14 @@ public: ...@@ -80,6 +87,14 @@ public:
_go_back_ns = go_back_ms * 1e6; _go_back_ns = go_back_ms * 1e6;
} }
void setBackend(Backend_t backend) {
_backend = backend;
}
void setScalingFactor(unsigned long long scalingFactor) {
_scaling_factor = scalingFactor;
}
private: private:
std::vector<reading_t> _buffer; std::vector<reading_t> _buffer;
std::vector<AggregatorSBPtr> _quantileSensors; std::vector<AggregatorSBPtr> _quantileSensors;
...@@ -90,6 +105,8 @@ private: ...@@ -90,6 +105,8 @@ private:
double _severity_max_memory; double _severity_max_memory;
std::vector<double> _severities; std::vector<double> _severities;
int _go_back_ns; int _go_back_ns;
Backend_t _backend;
unsigned long long _scaling_factor;
protected: protected:
virtual void compute(U_Ptr unit) override; virtual void compute(U_Ptr unit) override;
......
...@@ -153,9 +153,9 @@ void SMUCNGPerfConfigurator::operatorAttributes(SMUCNGPerfOperator& op, CFG_VAL ...@@ -153,9 +153,9 @@ void SMUCNGPerfConfigurator::operatorAttributes(SMUCNGPerfOperator& op, CFG_VAL
auto measurementInterval_s = std::stod(val.second.data())/1000.0; //miliseconds to seconds auto measurementInterval_s = std::stod(val.second.data())/1000.0; //miliseconds to seconds
op.setMeasuringInterval(measurementInterval_s); op.setMeasuringInterval(measurementInterval_s);
} else if(boost::iequals(val.first, "go_back_ms")) { } else if(boost::iequals(val.first, "go_back_ms")) {
auto go_back_ms = std::stod(val.second.data()); auto go_back_ms = std::stod(val.second.data());
op.setGoBackMs(go_back_ms); op.setGoBackMs(go_back_ms);
} }
} }
} }
......
...@@ -46,21 +46,21 @@ ...@@ -46,21 +46,21 @@
SMUCNGPerfOperator::SMUCNGPerfOperator(const std::string& name): OperatorTemplate(name), _go_back_ns(0), _measuring_interval_s(1) { SMUCNGPerfOperator::SMUCNGPerfOperator(const std::string& name): OperatorTemplate(name), _go_back_ns(0), _measuring_interval_s(1) {
_buffers.resize(64); _buffers.resize(64);
_metricToPerSecId[SMUCSensorBase::INSTRUCTIONS] = SMUCSensorBase::INSTRUCTIONS_PER_SECOND; _metricPerSecToId[SMUCSensorBase::INSTRUCTIONS_PER_SECOND] = SMUCSensorBase::INSTRUCTIONS;
_metricToPerSecId[SMUCSensorBase::ARITH_FPU_DIVIDER_ACTIVE] = SMUCSensorBase::EXPENSIVE_INSTRUCTIONS_PER_SECOND; _metricPerSecToId[SMUCSensorBase::EXPENSIVE_INSTRUCTIONS_PER_SECOND] = SMUCSensorBase::ARITH_FPU_DIVIDER_ACTIVE;
// _metricToPerSecId[SMUCSensorBase::L2_HITS] = SMUCSensorBase::L2_HITS_PER_SECOND; // _metricToPerSecId[SMUCSensorBase::L2_HITS] = SMUCSensorBase::L2_HITS_PER_SECOND;
_metricToPerSecId[SMUCSensorBase::L2_RQSTS_MISS] = SMUCSensorBase::L2_MISSES_PER_SECOND; _metricPerSecToId[SMUCSensorBase::L2_MISSES_PER_SECOND] = SMUCSensorBase::L2_RQSTS_MISS;
_metricToPerSecId[SMUCSensorBase::MEM_LOAD_RETIRED_L3_HIT] = SMUCSensorBase::L3_HITS_PER_SECOND; _metricPerSecToId[SMUCSensorBase::L3_HITS_PER_SECOND] = SMUCSensorBase::MEM_LOAD_RETIRED_L3_HIT;
_metricToPerSecId[SMUCSensorBase::MEM_LOAD_RETIRED_L3_MISS] = SMUCSensorBase::L3_MISSES_PER_SECOND; _metricPerSecToId[SMUCSensorBase::L3_MISSES_PER_SECOND] = SMUCSensorBase::MEM_LOAD_RETIRED_L3_MISS;
_metricToPerSecId[SMUCSensorBase::PERF_COUNT_HW_BRANCH_MISSES] = SMUCSensorBase::MISSBRANCHES_PER_SECOND; _metricPerSecToId[SMUCSensorBase::MISSBRANCHES_PER_SECOND] = SMUCSensorBase::PERF_COUNT_HW_BRANCH_MISSES;
_metricToPerSecId[SMUCSensorBase::NETWORK_XMIT] = SMUCSensorBase::NETWORK_BYTES_XMIT_PER_SECOND; _metricPerSecToId[SMUCSensorBase::NETWORK_BYTES_XMIT_PER_SECOND] = SMUCSensorBase::NETWORK_XMIT;
_metricToPerSecId[SMUCSensorBase::NETWORK_RCVD] = SMUCSensorBase::NETWORK_BYTES_RCVD_PER_SECOND; _metricPerSecToId[SMUCSensorBase::NETWORK_BYTES_RCVD_PER_SECOND] = SMUCSensorBase::NETWORK_RCVD;
_metricToPerSecId[SMUCSensorBase::IOOPENS] = SMUCSensorBase::IOOPENS_PER_SECOND; _metricPerSecToId[SMUCSensorBase::IOOPENS_PER_SECOND] = SMUCSensorBase::IOOPENS;
_metricToPerSecId[SMUCSensorBase::IOCLOSES] = SMUCSensorBase::IOCLOSES_PER_SECOND; _metricPerSecToId[SMUCSensorBase::IOCLOSES_PER_SECOND] = SMUCSensorBase::IOCLOSES;
_metricToPerSecId[SMUCSensorBase::IOBYTESREAD] = SMUCSensorBase::IOBYTESREAD_PER_SECOND; _metricPerSecToId[SMUCSensorBase::IOBYTESREAD_PER_SECOND] = SMUCSensorBase::IOBYTESREAD;
_metricToPerSecId[SMUCSensorBase::IOBYTESWRITE] = SMUCSensorBase::IOBYTESWRITE_PER_SECOND; _metricPerSecToId[SMUCSensorBase::IOBYTESWRITE_PER_SECOND] = SMUCSensorBase::IOBYTESWRITE;
_metricToPerSecId[SMUCSensorBase::IOREADS] = SMUCSensorBase::IOREADS_PER_SECOND; _metricPerSecToId[SMUCSensorBase::IOREADS_PER_SECOND] = SMUCSensorBase::IOREADS;
_metricToPerSecId[SMUCSensorBase::IOWRITES] = SMUCSensorBase::IOWRITES_PER_SECOND; _metricPerSecToId[SMUCSensorBase::IOWRITES_PER_SECOND] = SMUCSensorBase::IOWRITES;
} }
SMUCNGPerfOperator::~SMUCNGPerfOperator() { SMUCNGPerfOperator::~SMUCNGPerfOperator() {
...@@ -81,7 +81,7 @@ void SMUCNGPerfOperator::copy(const SMUCNGPerfOperator& other){ ...@@ -81,7 +81,7 @@ void SMUCNGPerfOperator::copy(const SMUCNGPerfOperator& other){
this->_metricToPosition = other._metricToPosition; this->_metricToPosition = other._metricToPosition;
this->_measuring_interval_s = other._measuring_interval_s; this->_measuring_interval_s = other._measuring_interval_s;
this->_go_back_ns = other._go_back_ns; this->_go_back_ns = other._go_back_ns;
this->_metricToPerSecId = other._metricToPerSecId; this->_metricPerSecToId = other._metricPerSecToId;
} }
void SMUCNGPerfOperator::printConfig(LOG_LEVEL ll) { void SMUCNGPerfOperator::printConfig(LOG_LEVEL ll) {
...@@ -121,7 +121,7 @@ void SMUCNGPerfOperator::compute(U_Ptr unit) { ...@@ -121,7 +121,7 @@ void SMUCNGPerfOperator::compute(U_Ptr unit) {
} else if (outSensor->getMetric() == SMUCSensorBase::MEMORY_BANDWIDTH) { } else if (outSensor->getMetric() == SMUCSensorBase::MEMORY_BANDWIDTH) {
computeMEMORY_BANDWIDTH(inputs, outSensor, timestamp); computeMEMORY_BANDWIDTH(inputs, outSensor, timestamp);
} else if (isAMetricPerSecond(outSensor->getMetric())){ } else if (isAMetricPerSecond(outSensor->getMetric())){
computeMetricPerSecond(_metricToPerSecId[outSensor->getMetric()], inputs, outSensor, timestamp); computeMetricPerSecond(outSensor->getMetric(), inputs, outSensor, timestamp);
} }
resetBuffers(); resetBuffers();
} }
...@@ -263,7 +263,8 @@ void SMUCNGPerfOperator::computeL3HIT_TO_L3MISS_RATIO(std::vector<SMUCNGPtr>& in ...@@ -263,7 +263,8 @@ void SMUCNGPerfOperator::computeL3HIT_TO_L3MISS_RATIO(std::vector<SMUCNGPtr>& in
} }
} }
void SMUCNGPerfOperator::computeMetricPerSecond(SMUCSensorBase::Metric_t metric, std::vector<SMUCNGPtr> &inputs, SMUCNGPtr& outSensor, const uint64_t timestamp) { void SMUCNGPerfOperator::computeMetricPerSecond(SMUCSensorBase::Metric_t metric_ps, std::vector<SMUCNGPtr> &inputs, SMUCNGPtr& outSensor, const uint64_t timestamp) {
SMUCSensorBase::Metric_t metric = _metricPerSecToId[metric_ps];
query(inputs[_metricToPosition[metric]]->getName(), timestamp, _buffers[0]); query(inputs[_metricToPosition[metric]]->getName(), timestamp, _buffers[0]);
reading_t metricpersec; reading_t metricpersec;
if(_buffers[0].size() > 0 && calculateMetricPerSec(_buffers[0][0], _measuring_interval_s, metricpersec)){ if(_buffers[0].size() > 0 && calculateMetricPerSec(_buffers[0][0], _measuring_interval_s, metricpersec)){
...@@ -323,23 +324,18 @@ void SMUCNGPerfOperator::computeMISSBRANCHES_TO_TOTAL_BRANCH_RATIO(std::vector<S ...@@ -323,23 +324,18 @@ void SMUCNGPerfOperator::computeMISSBRANCHES_TO_TOTAL_BRANCH_RATIO(std::vector<S
void SMUCNGPerfOperator::computeMEMORY_BANDWIDTH(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor, void SMUCNGPerfOperator::computeMEMORY_BANDWIDTH(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor,
const uint64_t timestamp) { const uint64_t timestamp) {
std::vector<reading_t> mem_counters; //ToDo how do I get them? std::vector<reading_t> mem_counters;
//ToDo
} }
bool SMUCNGPerfOperator::isAMetricPerSecond(SMUCSensorBase::Metric_t comp){ bool SMUCNGPerfOperator::isAMetricPerSecond(SMUCSensorBase::Metric_t comp){
if(comp == SMUCSensorBase::INSTRUCTIONS_PER_SECOND || if(comp == SMUCSensorBase::INSTRUCTIONS_PER_SECOND || comp == SMUCSensorBase::EXPENSIVE_INSTRUCTIONS_PER_SECOND ||
comp == SMUCSensorBase::EXPENSIVE_INSTRUCTIONS_PER_SECOND || comp == SMUCSensorBase::L2_HITS_PER_SECOND || comp == SMUCSensorBase::L2_HITS_PER_SECOND || comp == SMUCSensorBase::L2_MISSES_PER_SECOND ||
comp == SMUCSensorBase::L2_MISSES_PER_SECOND || comp == SMUCSensorBase::L3_HITS_PER_SECOND || comp == SMUCSensorBase::L3_MISSES_PER_SECOND ||
comp == SMUCSensorBase::L3_HITS_PER_SECOND || comp == SMUCSensorBase::MISSBRANCHES_PER_SECOND || comp == SMUCSensorBase::NETWORK_BYTES_XMIT_PER_SECOND ||
comp == SMUCSensorBase::L3_MISSES_PER_SECOND || comp == SMUCSensorBase::NETWORK_BYTES_RCVD_PER_SECOND || comp == SMUCSensorBase::IOOPENS_PER_SECOND ||
comp == SMUCSensorBase::MISSBRANCHES_PER_SECOND || comp == SMUCSensorBase::IOCLOSES_PER_SECOND || comp == SMUCSensorBase::IOBYTESREAD_PER_SECOND ||
comp == SMUCSensorBase::NETWORK_BYTES_XMIT_PER_SECOND || comp == SMUCSensorBase::IOBYTESWRITE_PER_SECOND || comp == SMUCSensorBase::IOREADS_PER_SECOND ||
comp == SMUCSensorBase::NETWORK_BYTES_RCVD_PER_SECOND ||
comp == SMUCSensorBase::IOOPENS_PER_SECOND ||
comp == SMUCSensorBase::IOCLOSES_PER_SECOND ||
comp == SMUCSensorBase::IOBYTESREAD_PER_SECOND ||
comp == SMUCSensorBase::IOBYTESWRITE_PER_SECOND ||
comp == SMUCSensorBase::IOREADS_PER_SECOND ||
comp == SMUCSensorBase::IOWRITES_PER_SECOND ){ comp == SMUCSensorBase::IOWRITES_PER_SECOND ){
return true; return true;
} }
......
...@@ -49,12 +49,12 @@ public: ...@@ -49,12 +49,12 @@ public:
_measuring_interval_s = measurement_interval_s; _measuring_interval_s = measurement_interval_s;
} }
void setGoBackMs(int go_back_ms){ void setGoBackMs(int go_back_ms){
_go_back_ns = go_back_ms * 1e6; _go_back_ns = go_back_ms * 1e6;
} }
protected: protected:
std::map<SMUCSensorBase::Metric_t, unsigned int> _metricToPosition; std::map<SMUCSensorBase::Metric_t, unsigned int> _metricToPosition;
std::map<SMUCSensorBase::Metric_t, SMUCSensorBase::Metric_t> _metricToPerSecId; std::map<SMUCSensorBase::Metric_t, SMUCSensorBase::Metric_t> _metricPerSecToId;
vector<vector<reading_t>> _buffers; vector<vector<reading_t>> _buffers;
const unsigned int MAX_FREQ_MHZ = 2700; const unsigned int MAX_FREQ_MHZ = 2700;
const unsigned int MIN_FREQ_MHZ = 1200; const unsigned int MIN_FREQ_MHZ = 1200;
......
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