Skip to content

Commit 84c9197

Browse files
committed
Added a member list of counter indices that will not be passed to the event manager to Chimbuko main class
Added ability to obtain the counter indices of the monitored counters from ADMonitoring; these are passed to the above ignore list so those counters aren't attached to function execution events Changed the default of ADMonitoring to capture all counters with the default prefix "monitoring: "; this should prevent any monitoring counters from appearing in the provDB in the default setup
1 parent 7dae3a7 commit 84c9197

5 files changed

Lines changed: 49 additions & 8 deletions

File tree

include/chimbuko/ad/ADMonitoring.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ namespace chimbuko {
108108
*/
109109
const std::unordered_map<std::string, std::string>& getWatchList() const{ return m_counter_watchlist; }
110110

111+
/**
112+
* @brief Get the indices of the counters associated with the monitoring plugin
113+
*/
114+
std::vector<int> getMonitoringCounterIndices() const;
115+
111116
private:
112117
bool m_state_set; /**< True if the state has been set at least once*/
113118
unsigned long m_timestamp; /**< The timestamp of the most recent update*/

include/chimbuko/chimbuko.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ namespace chimbuko {
279279
unsigned long long m_n_counter_events_accum_prd; /**< Total number of counter events since last write of periodic data*/
280280
unsigned long m_n_outliers_accum_prd; /**< Total number of outiers detected since last write of periodic data*/
281281
int m_n_steps_accum_prd; /**< Number of steps since last write of periodic data */
282+
283+
std::set<unsigned long> m_exec_ignore_counters; /**< Counter indices in this list are ignored by the event manager (but will still be picked up by other components)*/
282284
};
283285

284286
}

src/ad/ADMonitoring.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,7 @@ nlohmann::json ADMonitoring::get_json() const{
101101
}
102102

103103
void ADMonitoring::setDefaultWatchList(){
104-
addWatchedCounter("monitoring: Memory Footprint (VmRSS) (KB)", "Memory Footprint (VmRSS) (KB)");
105-
addWatchedCounter("monitoring: meminfo:MemAvailable (MB)", "Memory Available (MB)");
106-
addWatchedCounter("monitoring: meminfo:MemFree (MB)", "Memory Free (MB)");
107-
addWatchedCounter("monitoring: cpu: User %", "CPU Usage User (%)");
108-
addWatchedCounter("monitoring: cpu: System %", "CPU Usage System (%)");
109-
addWatchedCounter("monitoring: cpu: Idle %", "CPU Usage Idle (%)");
104+
setCounterPrefix("monitoring: "); //get all counters prefixed by "monitoring: " ; this prefix is set in the default tau_monitoring.json config file
110105
}
111106

112107
void ADMonitoring::parseWatchListFile(const std::string &file){
@@ -121,3 +116,11 @@ void ADMonitoring::parseWatchListFile(const std::string &file){
121116
addWatchedCounter(j_i[0],j_i[1]);
122117
}
123118
}
119+
120+
std::vector<int> ADMonitoring::getMonitoringCounterIndices() const{
121+
std::vector<int> out(m_cid_state_map.size());
122+
size_t i=0;
123+
for(auto const &e : m_cid_state_map)
124+
out[i++] = e.first;
125+
return out;
126+
}

src/chimbuko.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ void Chimbuko::finalize()
345345

346346
m_ptr_registry.resetPointers(); //delete all pointers in reverse order to which they were instantiated
347347
m_ptr_registry.deregisterPointers(); //allow them to be re-registered if init is called again
348+
349+
m_exec_ignore_counters.clear(); //reset the ignored counters list
348350

349351
m_is_initialized = false;
350352

@@ -439,8 +441,11 @@ void Chimbuko::extractEvents(unsigned long &first_event_ts,
439441
std::vector<Event_t> events = m_parser->getEvents();
440442
m_perf.add("ad_extract_events_get_events_ms", timer.elapsed_ms());
441443
timer.start();
442-
for(auto &e : events)
443-
m_event->addEvent(e);
444+
for(auto &e : events){
445+
if(e.type() != EventDataType::COUNT || !m_exec_ignore_counters.count(e.counter_id()) ){
446+
m_event->addEvent(e);
447+
}
448+
}
444449
m_perf.add("ad_extract_events_register_ms", timer.elapsed_ms());
445450
m_perf.add("ad_extract_events_event_count", events.size());
446451
if(events.size()){
@@ -474,6 +479,13 @@ void Chimbuko::extractNodeState(){
474479
if(!m_counter) throw std::runtime_error("Counter is not initialized");
475480
PerfTimer timer;
476481
m_monitoring->extractCounters(m_counter->getCountersByIndex());
482+
483+
//Get the counters that monitoring is watching and tell the event manager to ignore them so they don't get attached to any function execution
484+
std::vector<int> cidx_mon_ignore = m_monitoring->getMonitoringCounterIndices();
485+
for(int i: cidx_mon_ignore){
486+
m_exec_ignore_counters.insert(i);
487+
}
488+
477489
m_perf.add("ad_extract_node_state_ms", timer.elapsed_ms());
478490
}
479491

test/unit_tests/ad/ADMonitoring.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,22 @@ TEST(ADMonitoringTest, FilterPrefix){
140140

141141
EXPECT_TRUE(mon.hasState("interesting counter2")); //check the one not in the watch list is given the default name
142142
}
143+
144+
TEST(ADMonitoringTest, CounterIndices){
145+
std::unordered_map<int, std::string> counter_map = { {104,"interesting counter 1"}, {99,"interesting counter 2"} };
146+
ADMonitoring mon;
147+
148+
mon.linkCounterMap(&counter_map);
149+
150+
mon.addWatchedCounter("interesting counter 1", "my counter field 1");
151+
mon.addWatchedCounter("interesting counter 2", "my counter field 2");
152+
153+
CountersByIndex_t data; //don't actually need any observations of the counter for this but we do need to run extractCounters to setup the state buffer
154+
155+
mon.extractCounters(data);
156+
157+
std::vector<int> cidx = mon.getMonitoringCounterIndices();
158+
ASSERT_EQ(cidx.size(), 2);
159+
EXPECT_EQ(cidx[0], 99); //output will be ordered
160+
EXPECT_EQ(cidx[1], 104);
161+
}

0 commit comments

Comments
 (0)