Skip to content

Commit e8faefd

Browse files
committed
Removed HBOSOutlierTestBPFile and SSTDOutlierTestBPFile "unit tests" because they don't test anything!
Removed hacked-in output of some internal details of SSTD and HBOS/COPOD outlier detection in Anomalies output ADLocalNetClient now records the rank index provided such that get_client_rank returns the right value The above fixes GlobalAnomalyMetrics the unit test failing
1 parent 3c321c3 commit e8faefd

File tree

10 files changed

+8
-752
lines changed

10 files changed

+8
-752
lines changed

include/chimbuko/ad/ADNetClient.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ namespace chimbuko{
218218
/**
219219
* @brief connect to the parameter server
220220
*
221-
* @param rank Ignored
221+
* @param rank Stored as internal rank index
222222
* @param srank Ignored
223223
* @param sname Ignored
224224
*/

include/chimbuko/util/Anomalies.hpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,6 @@ namespace chimbuko{
1717
*/
1818
void insert(CallListIterator_t event, EventType type);
1919

20-
/**
21-
* @brief Insert used in HBOS for test purposes
22-
*/
23-
void insert(CallListIterator_t event, EventType type, double runtime, double hbos_score, double threshold);
24-
25-
/**
26-
* @brief Insert used in SSTD for test purposes
27-
*/
28-
void insert(CallListIterator_t event, EventType type, std::vector<double> thres_hilo_mean_std);
29-
30-
31-
const std::unordered_map<unsigned long, std::vector<std::vector<double> > > & allHbosScores() const{return m_func_outliers_hbos_scores_and_threshold;}
32-
33-
const std::unordered_map<unsigned long, std::vector<double> > & allSstdScores() const{return m_func_outliers_sstd_threshold_mean_std;}
34-
3520
/**
3621
* @brief Get the outlier/normal events associated with a given function
3722
*/
@@ -58,14 +43,6 @@ namespace chimbuko{
5843

5944
std::vector<CallListIterator_t> m_all_normal_execs; /**< Array of normal executions (the algorithm will capture a limited number of these for comparison with outliers)*/
6045
std::unordered_map<unsigned long, std::vector<CallListIterator_t> > m_func_normal_execs; /**< Map of function index to associated normal executions */
61-
62-
std::unordered_map<unsigned long, std::vector<std::vector<double> > > m_func_outliers_hbos_scores_and_threshold; /**< Map of function index to a 2D vector where index 0: HBOS scores, index 1: threshold */
63-
64-
std::unordered_map<unsigned long, std::vector<double> > m_func_outliers_sstd_threshold_mean_std; /**< Map of function index to a 2D vector where index 0: HBOS scores, index 1: threshold */
6546
};
6647

67-
68-
69-
70-
7148
};

src/ad/ADLocalAnomalyMetrics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ std::pair<size_t, size_t> ADLocalAnomalyMetrics::send(ADNetClient &net_client) c
6262
if (!net_client.use_ps())
6363
return std::make_pair(0, 0);
6464

65-
if(net_client.get_client_rank() != m_rank) fatal_error("Rank mismatch");
65+
if(net_client.get_client_rank() != m_rank) fatal_error("Rank mismatch: net client reported rank " + std::to_string(net_client.get_client_rank()) + " but recorded rank is " + std::to_string(m_rank) );
6666

6767
Message msg;
6868
msg.set_info(m_rank, net_client.get_server_rank(), MessageType::REQ_ADD, MessageKind::ANOMALY_METRICS, m_step);

src/ad/ADNetClient.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ std::string ADMPINetClient::send_and_receive(const Message &msg){
241241
void ADLocalNetClient::connect_ps(int rank, int srank, std::string sname){
242242
if(LocalNet::globalInstance() == nullptr) fatal_error("No LocalNet instance exists");
243243
m_use_ps = true;
244+
m_srank = 0;
245+
m_rank = rank;
244246
}
245247

246248

src/ad/ADOutlier.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,7 @@ unsigned long ADOutlierSSTD::compute_outliers(Anomalies &outliers,
242242
verboseStream << "!!!!!!!Detected outlier on func id " << func_id << " (" << itt->get_funcname() << ") on thread " << itt->get_tid()
243243
<< " runtime " << runtime << " mean " << mean << " std " << std << std::endl;
244244
n_outliers += 1;
245-
std::vector<double> sstd_stats{thr_hi, thr_lo, mean, std};
246-
outliers.insert(itt, Anomalies::EventType::Outlier, sstd_stats); //insert into data structure containing captured anomalies
245+
outliers.insert(itt, Anomalies::EventType::Outlier); //insert into data structure containing captured anomalies
247246
}else{
248247
//Capture maximum of one normal execution per io step
249248
if(outliers.nFuncEvents(func_id, Anomalies::EventType::Normal) == 0){
@@ -509,7 +508,7 @@ unsigned long ADOutlierHBOS::compute_outliers(Anomalies &outliers,
509508
if (ad_score >= l_threshold) {
510509
itt->set_label(-1);
511510
verboseStream << "!!!!!!!Detected outlier on func id " << func_id << " (" << itt->get_funcname() << ") on thread " << itt->get_tid() << " runtime " << runtime_i << " score " << ad_score << " (threshold " << l_threshold << ")" << std::endl;
512-
outliers.insert(itt, Anomalies::EventType::Outlier, runtime_i, ad_score, l_threshold); //insert into data structure containing captured anomalies
511+
outliers.insert(itt, Anomalies::EventType::Outlier); //insert into data structure containing captured anomalies
513512
n_outliers += 1;
514513
}else {
515514
//Capture maximum of one normal execution per io step
@@ -750,7 +749,7 @@ unsigned long ADOutlierCOPOD::compute_outliers(Anomalies &outliers,
750749
if (ad_score >= l_threshold) {
751750
itt->set_label(-1);
752751
verboseStream << "!!!!!!!Detected outlier on func id " << func_id << " (" << itt->get_funcname() << ") on thread " << itt->get_tid() << " runtime " << runtime_i << std::endl;
753-
outliers.insert(itt, Anomalies::EventType::Outlier, runtime_i, ad_score, l_threshold); //insert into data structure containing captured anomalies
752+
outliers.insert(itt, Anomalies::EventType::Outlier); //insert into data structure containing captured anomalies
754753
++n_outliers;
755754
}
756755
else {

src/util/Anomalies.cpp

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,6 @@ void Anomalies::insert(CallListIterator_t event, EventType type){
1717
}
1818
}
1919

20-
void Anomalies::insert(CallListIterator_t event, EventType type, double runtime, double hbos_score, double threshold) {
21-
switch(type){
22-
case EventType::Outlier:
23-
m_all_outliers.push_back(event);
24-
m_func_outliers[event->get_fid()].push_back(event);
25-
if(m_func_outliers_hbos_scores_and_threshold[event->get_fid()].size() == 0) {
26-
m_func_outliers_hbos_scores_and_threshold[event->get_fid()] = std::vector<std::vector<double> >(3);
27-
}
28-
m_func_outliers_hbos_scores_and_threshold[event->get_fid()].at(0).push_back(runtime);
29-
m_func_outliers_hbos_scores_and_threshold[event->get_fid()].at(1).push_back(hbos_score);
30-
m_func_outliers_hbos_scores_and_threshold[event->get_fid()].at(2).push_back(threshold);
31-
break;
32-
case EventType::Normal:
33-
m_all_normal_execs.push_back(event);
34-
m_func_normal_execs[event->get_fid()].push_back(event);
35-
break;
36-
default:
37-
throw std::runtime_error("Invalid type");
38-
}
39-
}
40-
41-
void Anomalies::insert(CallListIterator_t event, EventType type, std::vector<double> thres_hilo_mean_std) {
42-
switch(type){
43-
case EventType::Outlier:
44-
m_all_outliers.push_back(event);
45-
m_func_outliers[event->get_fid()].push_back(event);
46-
47-
m_func_outliers_sstd_threshold_mean_std[event->get_fid()].push_back(thres_hilo_mean_std[0]);
48-
m_func_outliers_sstd_threshold_mean_std[event->get_fid()].push_back(thres_hilo_mean_std[1]);
49-
m_func_outliers_sstd_threshold_mean_std[event->get_fid()].push_back(thres_hilo_mean_std[2]);
50-
m_func_outliers_sstd_threshold_mean_std[event->get_fid()].push_back(thres_hilo_mean_std[3]);
51-
break;
52-
case EventType::Normal:
53-
m_all_normal_execs.push_back(event);
54-
m_func_normal_execs[event->get_fid()].push_back(event);
55-
break;
56-
default:
57-
throw std::runtime_error("Invalid type");
58-
}
59-
}
60-
6120
const std::vector<CallListIterator_t> & Anomalies::funcEvents(const unsigned long func_id, EventType type) const{
6221
static std::vector<CallListIterator_t> empty;
6322
auto const &mp = type == EventType::Outlier ? m_func_outliers : m_func_normal_execs;

0 commit comments

Comments
 (0)