Commit 3560431c authored by Sebastien Marchand's avatar Sebastien Marchand Committed by Commit Bot

Make the startup pagefault count be gathered from a background task


Make Startup.BrowserMessageLoopStartHardFaultCount be gathered from a
TaskPriority::BACKGROUND task

Bug: 784853
Change-Id: Ia8772f9e66a20dabbd6e8fd7c73588bed421f9bc
Reviewed-on: https://chromium-review.googlesource.com/884377
Commit-Queue: Sébastien Marchand <sebmarchand@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533912}
parent 18e528eb
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#include "base/profiler/stack_sampling_profiler.h" #include "base/profiler/stack_sampling_profiler.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/sys_info.h" #include "base/sys_info.h"
#include "base/task_scheduler/post_task.h"
#include "base/task_scheduler/task_traits.h"
#include "base/threading/platform_thread.h" #include "base/threading/platform_thread.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "build/build_config.h" #include "build/build_config.h"
...@@ -320,10 +322,10 @@ void RecordSystemUptimeHistogram() { ...@@ -320,10 +322,10 @@ void RecordSystemUptimeHistogram() {
} }
// On Windows, records the number of hard-faults that have occurred in the // On Windows, records the number of hard-faults that have occurred in the
// current chrome.exe process since it was started. This is a nop on other // current chrome.exe process since it was started. This function uses an
// platforms. // expensive system call and should preferably be used in a background thread.
void RecordHardFaultHistogram() {
#if defined(OS_WIN) #if defined(OS_WIN)
void RecordHardFaultHistogram() {
uint32_t hard_fault_count = 0; uint32_t hard_fault_count = 0;
// Don't record histograms if unable to get the hard fault count. // Don't record histograms if unable to get the hard fault count.
...@@ -374,8 +376,8 @@ void RecordHardFaultHistogram() { ...@@ -374,8 +376,8 @@ void RecordHardFaultHistogram() {
base::HistogramBase::kUmaTargetedHistogramFlag) base::HistogramBase::kUmaTargetedHistogramFlag)
->Add(g_startup_temperature); ->Add(g_startup_temperature);
} }
#endif // defined(OS_WIN)
} }
#endif // defined(OS_WIN)
// Converts a base::Time value to a base::TimeTicks value. The conversion isn't // Converts a base::Time value to a base::TimeTicks value. The conversion isn't
// exact, but by capturing Time::Now() as early as possible, the likelihood of a // exact, but by capturing Time::Now() as early as possible, the likelihood of a
...@@ -568,7 +570,14 @@ void RecordBrowserMainMessageLoopStart(base::TimeTicks ticks, ...@@ -568,7 +570,14 @@ void RecordBrowserMainMessageLoopStart(base::TimeTicks ticks,
// histograms depend on it setting |g_startup_temperature| and // histograms depend on it setting |g_startup_temperature| and
// |g_startups_with_current_version|. // |g_startups_with_current_version|.
RecordSameVersionStartupCount(pref_service); RecordSameVersionStartupCount(pref_service);
RecordHardFaultHistogram(); #if defined(OS_WIN)
// Record the hard page fault count in a background thread as this is quite
// expensive to compute.
base::PostTaskWithTraits(FROM_HERE,
{base::TaskPriority::BACKGROUND,
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
base::BindOnce(&RecordHardFaultHistogram));
#endif
// Record timing of the browser message-loop start time. // Record timing of the browser message-loop start time.
base::StackSamplingProfiler::SetProcessMilestone( base::StackSamplingProfiler::SetProcessMilestone(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment