MCPcopy Create free account
hub / github.com/3rdparty/libprocess / start

Method start

src/profiler.cpp:61–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59
60
61Future<http::Response> Profiler::start(
62 const http::Request& request,
63 const Option<http::authentication::Principal>&)
64{
65#ifdef ENABLE_GPERFTOOLS
66 const Option<std::string>
67 enableProfiler = os::getenv("LIBPROCESS_ENABLE_PROFILER");
68 if (enableProfiler.isNone() || enableProfiler.get() != "1") {
69 return http::BadRequest(
70 "The profiler is not enabled. To enable the profiler, libprocess "
71 "must be started with LIBPROCESS_ENABLE_PROFILER=1 in the "
72 "environment.\n");
73 }
74
75 if (started) {
76 return http::BadRequest("Profiler already started.\n");
77 }
78
79 LOG(INFO) << "Starting Profiler";
80
81 // WARNING: If using libunwind < 1.0.1, profiling should not be used, as
82 // there are reports of crashes.
83 // WARNING: If using libunwind 1.0.1, profiling should not be turned on
84 // when it's possible for new threads to be created.
85 // This may cause a deadlock. The workaround used in libprocess is described
86 // here:
87 // https://groups.google.com/d/topic/google-perftools/Df10Uy4Djrg/discussion
88 // NOTE: We have not tested this with libunwind > 1.0.1.
89 if (!ProfilerStart(PROFILE_FILE)) {
90 Try<std::string> error =
91 strings::format("Failed to start profiler: %s", os::strerror(errno));
92 LOG(ERROR) << error.get();
93 return http::InternalServerError(error.get());
94 }
95
96 started = true;
97 return http::OK("Profiler started.\n");
98#else
99 return http::BadRequest(
100 "Perftools is disabled. To enable perftools, "
101 "configure libprocess with --enable-perftools.\n");
102#endif
103}
104
105
106Future<http::Response> Profiler::stop(

Callers 7

verifyFunction · 0.45
TEST_FFunction · 0.45
_runMethod · 0.45
TESTFunction · 0.45
runMethod · 0.45
runMethod · 0.45
TEST_PFunction · 0.45

Calls 4

BadRequestClass · 0.85
InternalServerErrorClass · 0.85
OKClass · 0.85
getMethod · 0.45

Tested by 6

TEST_FFunction · 0.36
_runMethod · 0.36
TESTFunction · 0.36
runMethod · 0.36
runMethod · 0.36
TEST_PFunction · 0.36