Skip to content

Commit b4d20de

Browse files
committed
Merge branch 'ckelly_develop' of https://github.com/CODARcode/PerformanceAnalysis into ckelly_develop
2 parents 35d8a42 + 46a713e commit b4d20de

3 files changed

Lines changed: 58 additions & 7 deletions

File tree

sphinx/source/io_schema/pserver_schema.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ The schema for the **'anomaly_stats'** object is as follows:
7575
| ...
7676
| ],
7777
| **'key'**: *A string label of the form "$PROGRAM ID:$RANK" (eg "0:12")*,
78-
| **'stats'**: *Statistics on anomalies on this process/rank over the steps broken down above (object)*
78+
| **'stats'**: *Statistics on anomalies on this process/rank over all steps to date
7979
| {
8080
| **'accumulate'**: *Total anomalies*,
8181
| **'count'**: *Number of io steps included in statistics*,

src/pserver/global_anomaly_stats.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,34 @@ nlohmann::json GlobalAnomalyStats::collect_stat_data(){
7272
//AnomalyStat contains statistics on the number of anomalies found per io step and also a set of AnomalyData objects
7373
//that have been collected from that rank since the last flush
7474
for(auto & pp : m_anomaly_stats){
75-
int pid = pp.first;
75+
int pid = pp.first; //pid
7676
for(auto & rp: pp.second){
77-
unsigned long rid = rp.first;
77+
unsigned long rid = rp.first; //rank
7878

7979
auto stats = rp.second.get(); //returns a std::pair<RunStats, std::list<AnomalyData>*>, and flushes the state of pair.second.
8080
//We now own the std::list<AnomalyData>* pointer and have to delete it
8181

8282
if(stats.second){
83-
if(stats.second->size()){
83+
//Decide whether to include the data for this pid/rid
84+
//Do this only if any anomalies were seen since the last call
85+
bool include = false;
86+
for(const AnomalyData &adata: *stats.second){
87+
if(adata.get_n_anomalies() > 0){
88+
include = true;
89+
break;
90+
}
91+
}
92+
93+
if(include){
8494
nlohmann::json object;
8595
object["key"] = stringize("%d:%d", pid,rid);
86-
object["stats"] = stats.first.get_json();
96+
object["stats"] = stats.first.get_json(); //statistics on anomalies to date for this pid/rid
8797

8898
object["data"] = nlohmann::json::array();
89-
for (auto const &adata: *stats.second){
90-
object["data"].push_back(adata.get_json());
99+
for (const AnomalyData &adata: *stats.second){
100+
//Don't include data for which there are no anomalies
101+
if(adata.get_n_anomalies()>0)
102+
object["data"].push_back(adata.get_json());
91103
}
92104
jsonObjects.push_back(object);
93105
}

test/unit_tests/pserver/global_anomaly_stats.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,44 @@ TEST(TestGlobalAnomalyStats, UpdateAnomalyStat){
107107
//Check data was flushed
108108
adata = astats.get_data();
109109
EXPECT_EQ(adata->size(), 0);
110+
111+
//Check that collect_stat_data only includes data if the number of anomalies seen since last collect > 0
112+
int step3= 2;
113+
int min_ts3 = 2000;
114+
int max_ts3 = 3000;
115+
int n_anomalies3 = 0;
116+
117+
AnomalyData d3(app, rank, step3, min_ts3, max_ts3, n_anomalies3);
118+
119+
stats.update_anomaly_stat(d3);
120+
121+
astats_j = stats.collect_stat_data();
122+
EXPECT_EQ(astats_j.is_array(), true );
123+
EXPECT_EQ(astats_j.size(), 0 );
124+
125+
//Check that if there are multiple steps, some of which have anomalies, that the data array only contains the data with nanom > 0
126+
127+
int step4= 3;
128+
int min_ts4 = 3000;
129+
int max_ts4 = 4000;
130+
int n_anomalies4 = 0;
131+
132+
AnomalyData d4(app, rank, step4, min_ts4, max_ts4, n_anomalies4);
133+
134+
int step5= 4;
135+
int min_ts5 = 4000;
136+
int max_ts5 = 5000;
137+
int n_anomalies5 = 10;
138+
139+
AnomalyData d5(app, rank, step5, min_ts5, max_ts5, n_anomalies5);
140+
141+
stats.update_anomaly_stat(d4);
142+
stats.update_anomaly_stat(d5);
143+
144+
astats_j = stats.collect_stat_data();
145+
EXPECT_EQ(astats_j.is_array(), true );
146+
EXPECT_EQ(astats_j.size(), 1 ); //1 rank
147+
EXPECT_EQ(astats_j[0]["data"].size(), 1); //only d5
148+
EXPECT_EQ(astats_j[0]["data"][0]["step"], step5);
110149
}
111150

0 commit comments

Comments
 (0)