From 48660e9ce5b8907f6e23d386f47bce8346d97260 Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Thu, 7 Dec 2017 19:25:23 -0800 Subject: [PATCH] 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. --- fdbserver/workloads/CpuProfiler.actor.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/fdbserver/workloads/CpuProfiler.actor.cpp b/fdbserver/workloads/CpuProfiler.actor.cpp index 13772ccff9..59bc54e2b4 100644 --- a/fdbserver/workloads/CpuProfiler.actor.cpp +++ b/fdbserver/workloads/CpuProfiler.actor.cpp @@ -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 roles; + //A list of worker interfaces which have had profiling turned on std::vector 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()); success = true; } @@ -66,8 +71,11 @@ struct CpuProfilerWorkload : TestWorkload { vector> _workers = wait( getWorkers( self->dbInfo ) ); vector 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(); }