summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorscottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-12 20:01:37 +0000
committerscottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-12 20:01:37 +0000
commit0a4cd3111631b21bdb07732ea037bbe40785590c (patch)
tree43403693f0e011f1d212ff56a5bf5be221f55b12 /base
parent461749a8adf21103afe9807be1633ac950bce976 (diff)
downloadchromium_src-0a4cd3111631b21bdb07732ea037bbe40785590c.zip
chromium_src-0a4cd3111631b21bdb07732ea037bbe40785590c.tar.gz
chromium_src-0a4cd3111631b21bdb07732ea037bbe40785590c.tar.bz2
Profiling for the renderer process.
This lets you use --profiling-at-start=renderer and get profiler output for each renderer process started on Linux. The profiling classes are initialized at static initialization time, and the main thread is registered and the profile timer is started at that time. However, static initialization is done in the zygote, and the timer doesn't propagate across the fork, so trying to use the CPU profiler on the renderer never sampled. This patch re-registers the (new) main thread after the fork, which causes the profiler to check the state of the timer, and ends up re-starting it. A separate timer for flushing the profile and termination signal handler are added before the renderer process enters the sandbox in order to make sure the samples are written to disk. BUG=none TEST=Use it, get lovely traces, pperf away. Review URL: http://codereview.chromium.org/8083025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105134 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/debug/profiler.cc9
-rw-r--r--base/debug/profiler.h3
2 files changed, 11 insertions, 1 deletions
diff --git a/base/debug/profiler.cc b/base/debug/profiler.cc
index e62b6b6..be442cf 100644
--- a/base/debug/profiler.cc
+++ b/base/debug/profiler.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -44,6 +44,10 @@ bool BeingProfiled() {
return ProfilingIsEnabledForAllThreads();
}
+void RestartProfilingAfterFork() {
+ ProfilerRegisterThread();
+}
+
#else
void StartProfiling(const std::string& name) {
@@ -59,6 +63,9 @@ bool BeingProfiled() {
return false;
}
+void RestartProfilingAfterFork() {
+}
+
#endif
} // namespace debug
diff --git a/base/debug/profiler.h b/base/debug/profiler.h
index a8f1297..69795a5 100644
--- a/base/debug/profiler.h
+++ b/base/debug/profiler.h
@@ -31,6 +31,9 @@ BASE_EXPORT void FlushProfiling();
// Returns true if process is being profiled.
BASE_EXPORT bool BeingProfiled();
+// Reset profiling after a fork, which disables timers.
+BASE_EXPORT void RestartProfilingAfterFork();
+
} // namespace debug
} // namespace base