MCPcopy Create free account
hub / github.com/apple/foundationdb / updateCpuProfiler

Function updateCpuProfiler

fdbserver/worker.actor.cpp:1104–1143  ·  view source on GitHub ↗

Starts or stops the CPU profiler

Source from the content-addressed store, hash-verified

1102
1103// Starts or stops the CPU profiler
1104void updateCpuProfiler(ProfilerRequest req) {
1105 switch (req.type) {
1106 case ProfilerRequest::Type::GPROF:
1107#if (defined(__linux__) || defined(__FreeBSD__)) && defined(USE_GPERFTOOLS) && !defined(VALGRIND)
1108 switch (req.action) {
1109 case ProfilerRequest::Action::ENABLE: {
1110 const char* path = (const char*)req.outputFile.begin();
1111 ProfilerOptions* options = new ProfilerOptions();
1112 options->filter_in_thread = &filter_in_thread;
1113 options->filter_in_thread_arg = nullptr;
1114 ProfilerStartWithOptions(path, options);
1115 break;
1116 }
1117 case ProfilerRequest::Action::DISABLE:
1118 ProfilerStop();
1119 break;
1120 case ProfilerRequest::Action::RUN:
1121 ASSERT(false); // User should have called runProfiler.
1122 break;
1123 }
1124#endif
1125 break;
1126 case ProfilerRequest::Type::FLOW:
1127 switch (req.action) {
1128 case ProfilerRequest::Action::ENABLE:
1129 startProfiling(g_network, {}, req.outputFile);
1130 break;
1131 case ProfilerRequest::Action::DISABLE:
1132 stopProfiling();
1133 break;
1134 case ProfilerRequest::Action::RUN:
1135 ASSERT(false); // User should have called runProfiler.
1136 break;
1137 }
1138 break;
1139 default:
1140 ASSERT(false);
1141 break;
1142 }
1143}
1144
1145ACTOR Future<Void> runCpuProfiler(ProfilerRequest req) {
1146 if (req.action == ProfilerRequest::Action::RUN) {

Callers 1

Calls 3

startProfilingFunction · 0.85
stopProfilingFunction · 0.85
beginMethod · 0.45

Tested by

no test coverage detected