Commit 1a968c70 authored by Micha Müller's avatar Micha Müller
Browse files

Pusher: Caliper service: drop node data and rewrite comments

parent 6027019d
......@@ -102,7 +102,9 @@ private:
/**
* Look up to which object file a given program counter points. This is done
* by checking the address ranges in /proc/self/maps.
* by checking a local cache of address ranges in /proc/self/maps. If no
* matching address range is found we rebuild the internal cache and try
* once again.
*/
std::string lookup_pathname(unsigned long long pc, Channel* chn, bool retry=false) {
//we get blocked here if proc_map is currently rebuild
......@@ -135,10 +137,10 @@ private:
* Setup proc_map. Parse all address ranges and their pathnames which are
* marked as executable from /proc/self/maps.
*
* This method is called once on start-up and possibly if a new memory
* region with executable code is mapped (dynamic library load, self
* modifying code). However, the latter case is not expected to occur very
* often.
* This method is called once on start-up and every time lookup_pathname
* fails. Lookup_pathname can fail if a new memory region with executable
* code is mapped (dynamic library load, self modifying code), which is not
* yet in the local cache.
*/
bool setup_proc_map(Channel* chn) {
if (writer_lock.test_and_set(std::memory_order_acquire)) {
......@@ -203,20 +205,22 @@ private:
// manually issue a pre-flush event to set up the SymbolLookup service
chn->events().pre_flush_evt(c, chn, nullptr);
// Check if required services sampler, symbollookup and timestamp are
// active by searching for identifying attributes.
// Check if required services sampler, symbollookup, timestamp and
// pthread are active by searching for identifying attributes.
//TODO support data collection if event triggered snapshots are used
sampler_pc = c->get_attribute("cali.sampler.pc");
sampler_fun = c->get_attribute("source.function#cali.sampler.pc");
timestamp = c->get_attribute("time.timestamp");
thread_id = c->get_attribute("pthread.id");
if (sampler_pc == Attribute::invalid ||
sampler_fun == Attribute::invalid ||
timestamp == Attribute::invalid) {
timestamp == Attribute::invalid ||
thread_id == Attribute::invalid) {
Log(1).stream() << chn->name() << ": DcdbPusher: not all required services "
"sampler, symbollookup and timestamp are running." << std::endl;
"sampler, symbollookup, timestamp and pthread are running." << std::endl;
return;
}
......@@ -275,8 +279,7 @@ private:
// symbollookup data
chn->events().postprocess_snapshot(c, chn, rec);
const size_t bufSize = 2048;
char buf[bufSize];
char buf[2048];
std::string time;
std::string value;
std::string func_name;
......@@ -286,6 +289,7 @@ private:
//look up required attribute values in snapshot
cali_id_t entryId = c->get_attribute(e.attribute()).id();
if (entryId == timestamp.id()) {
time = e.value().to_string();
} else if (entryId == sampler_fun.id()) {
......@@ -296,29 +300,31 @@ private:
}
}
value = file_name + "::" + func_name;
#if __GLIBC_PREREQ(2, 29)
unsigned cpu, node;
unsigned cpu;
if (!getcpu(&cpu, &node)) {
value += "/node" + std::to_string(node) + "/cpu" + std::to_string(cpu);
if (!getcpu(&cpu, NULL)) {
value = "/cpu" + std::to_string(cpu);
}
#else
int cpu = sched_getcpu();
if (cpu != -1) {
value += "/cpu" + std::to_string(cpu);
value = "/cpu" + std::to_string(cpu);
}
#endif
value += "/" + file_name + "/" + func_name;
if ((value.length() + time.length() + 2) > 2048) {
Log(1).stream() << chn->name() << ": DcdbPusher: value exceeding buffer size" << std::endl;
++snapshots_failed;
return;
}
Log(1).stream() << chn->name() << ": DcdbPusher: sending value "
<< value << " (" << time << ")" << std::endl << std::endl;
#if 0
Log(1).stream() << chn->name() << ": DcdbPusher: Sending \""
<< value << "\" (" << time << ")" << std::endl << std::endl;
#endif
strncpy(buf, time.c_str(), time.length()+1);
strncpy(&buf[time.length()+1], value.c_str(), value.length()+1);
......
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