diff options
author | qsr@chromium.org <qsr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-11 12:49:17 +0000 |
---|---|---|
committer | qsr@chromium.org <qsr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-11 12:49:17 +0000 |
commit | 915b344f5c907df65e6f21cda93d6f7859b1f853 (patch) | |
tree | 431505a67d9833b6082e4b62b2c8d16ec639b3b4 | |
parent | b7b044b56959787c43498e3fb8e644cff8ba3cb4 (diff) | |
download | chromium_src-915b344f5c907df65e6f21cda93d6f7859b1f853.zip chromium_src-915b344f5c907df65e6f21cda93d6f7859b1f853.tar.gz chromium_src-915b344f5c907df65e6f21cda93d6f7859b1f853.tar.bz2 |
Disable timing from chrome://profiler on Android.
On Android, on a arm CPU, TimeTicks::Now() is taking 900ns (20 times
what it takes on a desktop x86 CPU). The bigger user of TimeTicks::Now()
is tracked_objects::TrackedTime, and this impacts the overall
performance of Chrome on this platform.
This CL adds compile line flags that allows to disable
tracked_objects::TrackedTime. It also disable
tracked_objects::TrackedTime by default on Android.
BUG=315070
Review URL: https://codereview.chromium.org/99343002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240092 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/base_switches.cc | 8 | ||||
-rw-r--r-- | base/base_switches.h | 4 | ||||
-rw-r--r-- | base/tracked_objects.cc | 26 | ||||
-rw-r--r-- | content/browser/android/content_startup_flags.cc | 7 | ||||
-rw-r--r-- | content/browser/renderer_host/render_process_host_impl.cc | 1 |
5 files changed, 44 insertions, 2 deletions
diff --git a/base/base_switches.cc b/base/base_switches.cc index 526633c..91e401c 100644 --- a/base/base_switches.cc +++ b/base/base_switches.cc @@ -54,6 +54,14 @@ const char kWaitForDebugger[] = "wait-for-debugger"; // Sends a pretty-printed version of tracing info to the console. const char kTraceToConsole[] = "trace-to-console"; +// Configure whether chrome://profiler will contain timing information. This +// option is enabled by default. A value of "0" will disable profiler timing, +// while all other values will enable it. +const char kProfilerTiming[] = "profiler-timing"; +// Value of the --profiler-timing flag that will disable timing information for +// chrome://profiler. +const char kProfilerTimingDisabledValue[] = "0"; + #if defined(OS_POSIX) // Used for turning on Breakpad crash reporting in a debug environment where // crash reporting is typically compiled but disabled. diff --git a/base/base_switches.h b/base/base_switches.h index b2bf7ab..b679e6d 100644 --- a/base/base_switches.h +++ b/base/base_switches.h @@ -17,11 +17,13 @@ extern const char kEnableCrashReporter[]; extern const char kEnableDCHECK[]; extern const char kFullMemoryCrashReport[]; extern const char kNoErrorDialogs[]; +extern const char kProfilerTiming[]; +extern const char kProfilerTimingDisabledValue[]; extern const char kTestChildProcess[]; +extern const char kTraceToConsole[]; extern const char kV[]; extern const char kVModule[]; extern const char kWaitForDebugger[]; -extern const char kTraceToConsole[]; #if defined(OS_POSIX) extern const char kEnableCrashReporterForTesting[]; diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc index 0847d5f..72049e4 100644 --- a/base/tracked_objects.cc +++ b/base/tracked_objects.cc @@ -7,6 +7,8 @@ #include <limits.h> #include <stdlib.h> +#include "base/base_switches.h" +#include "base/command_line.h" #include "base/compiler_specific.h" #include "base/debug/leak_annotations.h" #include "base/logging.h" @@ -51,6 +53,28 @@ const ThreadData::Status kInitialStartupState = // problem with its presence). static const bool kAllowAlternateTimeSourceHandling = true; +inline bool IsProfilerTimingEnabled() { + static enum { + UNDEFINED_TIMING, + ENABLED_TIMING, + DISABLED_TIMING, + } timing_enabled = UNDEFINED_TIMING; + // This initialization is not thread-safe, so the value of |timing_enabled| + // can be computed multiple times. This is not an issue, as the computed value + // will always be the same, and is side-effect free, while needing to use a + // lock or a memory barrier would be more costly. + if (timing_enabled == UNDEFINED_TIMING) { + if (!CommandLine::InitializedForCurrentProcess()) + return true; + timing_enabled = (CommandLine::ForCurrentProcess()->GetSwitchValueASCII( + switches::kProfilerTiming) == + switches::kProfilerTimingDisabledValue) + ? DISABLED_TIMING + : ENABLED_TIMING; + } + return timing_enabled == ENABLED_TIMING; +} + } // namespace //------------------------------------------------------------------------------ @@ -754,7 +778,7 @@ void ThreadData::SetAlternateTimeSource(NowFunction* now_function) { TrackedTime ThreadData::Now() { if (kAllowAlternateTimeSourceHandling && now_function_) return TrackedTime::FromMilliseconds((*now_function_)()); - if (kTrackAllTaskObjects && TrackingStatus()) + if (kTrackAllTaskObjects && IsProfilerTimingEnabled() && TrackingStatus()) return TrackedTime::Now(); return TrackedTime(); // Super fast when disabled, or not compiled. } diff --git a/content/browser/android/content_startup_flags.cc b/content/browser/android/content_startup_flags.cc index 737fd7c..7d95034 100644 --- a/content/browser/android/content_startup_flags.cc +++ b/content/browser/android/content_startup_flags.cc @@ -4,6 +4,7 @@ #include "content/browser/android/content_startup_flags.h" +#include "base/base_switches.h" #include "base/command_line.h" #include "base/logging.h" #include "base/strings/string_number_conversions.h" @@ -89,6 +90,12 @@ void SetContentCommandLineFlags(int max_render_process_count, parsed_command_line->AppendSwitchNative( switches::kRegisterPepperPlugins, plugin_descriptor); } + + // Disable profiler timing by default. + if (!parsed_command_line->HasSwitch(switches::kProfilerTiming)) { + parsed_command_line->AppendSwitchASCII( + switches::kProfilerTiming, switches::kProfilerTimingDisabledValue); + } } } // namespace content diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 5018c54..231b59d 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -1037,6 +1037,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( switches::kNoReferrers, switches::kNoSandbox, switches::kPpapiInProcess, + switches::kProfilerTiming, switches::kRegisterPepperPlugins, switches::kRendererAssertTest, switches::kRendererStartupDialog, |