Add class restrictions to CpuProfiler, and fix metric crash.

This change largely refactors away the old meaning of the value given to
flow_profiler, which was the number of machines that we'd be profiling, and
instead replaces it with the classes of processes to profile for the duration
of the test.  Most importantly, this means that one can profile in circus with
a configuration that has "ssd" in it, and the circus run will still complete
(as long as the argument isn't "storage").

And also finally add some other fixes I had to the same file to conditionally
change the name of the metric we're looking for to comply with what's actually
written.
This commit is contained in:
Alex Miller 2017-12-07 19:25:23 -08:00
parent abb2dd1ebc
commit 48660e9ce5
1 changed files with 10 additions and 12 deletions

View File

@ -35,6 +35,10 @@ struct CpuProfilerWorkload : TestWorkload
//How long the profiler should be run; if <= 0 then it will run until the workload's check function is called
double duration;
//What process classes should be profiled as part of this run?
//See Locality.h for the list of valid strings to provide.
vector<std::string> roles;
//A list of worker interfaces which have had profiling turned on
std::vector<WorkerInterface> profilingWorkers;
@ -43,6 +47,7 @@ struct CpuProfilerWorkload : TestWorkload
{
initialDelay = getOption(options, LiteralStringRef("initialDelay"), 0.0);
duration = getOption(options, LiteralStringRef("duration"), -1.0);
roles = getOption(options, LiteralStringRef("roles"), vector<std::string>());
success = true;
}
@ -66,8 +71,11 @@ struct CpuProfilerWorkload : TestWorkload
{
vector<std::pair<WorkerInterface, ProcessClass>> _workers = wait( getWorkers( self->dbInfo ) );
vector<WorkerInterface> workers;
for(int i = 0; i < _workers.size(); i++)
workers.push_back(_workers[i].first);
for(int i = 0; i < _workers.size(); i++) {
if (self->roles.empty() || std::find(self->roles.cbegin(), self->roles.cend(), _workers[i].second.toString()) != self->roles.cend()) {
workers.push_back(_workers[i].first);
}
}
self->profilingWorkers = workers;
}
@ -98,16 +106,6 @@ struct CpuProfilerWorkload : TestWorkload
TraceEvent("DoneSignalingProfiler");
}
// Profiling the testers is already covered above, as the workers listed include all testers.
// TODO(alexmiller): Create role-restricted profiling, and consider restoring the below.
// Enable (or disable) the profiler on the current tester
// ProfilerRequest req;
// req.type = ProfilerRequest::Type::FLOW;
// req.action = enabled ? ProfilerRequest::Action::ENABLE : ProfilerRequest::Action::DISABLE;
// req.duration = 0; //unused
// req.outputFile = StringRef(SERVER_KNOBS->LOG_DIRECTORY + "/" + toIPString(g_network->getLocalAddress().ip) + "." + format("%d", g_network->getLocalAddress().port) + ".profile.local.bin");
// updateCpuProfiler(req);
return Void();
}