Commit 34bcfd7e authored by Mike Wittman's avatar Mike Wittman Committed by Commit Bot

[Sampling profiler] Enable new profile builder at 50%

Server-side handling of the 1% of startup profiles has been validated.
Increase to 50% of all profiles to provide equivalent data for
comparison and validation of profile sizes.

Bug: 851163
Change-Id: Ib34239b7179939857667b8de9633b57ce247494f
Reviewed-on: https://chromium-review.googlesource.com/c/1342857
Commit-Queue: Mike Wittman <wittman@chromium.org>
Reviewed-by: default avatarXi Cheng <chengx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609414}
parent fa612fd9
...@@ -66,6 +66,20 @@ CallStackProfileParams::Process GetProcess() { ...@@ -66,6 +66,20 @@ CallStackProfileParams::Process GetProcess() {
return CallStackProfileParams::UNKNOWN_PROCESS; return CallStackProfileParams::UNKNOWN_PROCESS;
} }
std::unique_ptr<base::StackSamplingProfiler::ProfileBuilder>
CreateProfileBuilder(
const CallStackProfileParams& params,
base::OnceClosure completed_callback = base::OnceClosure()) {
// Enable the new profile builder half the time.
if (base::RandInt(0, 99) < 50) {
return std::make_unique<CallStackProfileBuilder>(
params, std::move(completed_callback));
}
return std::make_unique<LegacyCallStackProfileBuilder>(
params, std::move(completed_callback));
}
} // namespace } // namespace
// The scheduler works by splitting execution time into repeated periods such // The scheduler works by splitting execution time into repeated periods such
...@@ -193,29 +207,16 @@ void ThreadProfiler::SetServiceManagerConnectorForChildProcess( ...@@ -193,29 +207,16 @@ void ThreadProfiler::SetServiceManagerConnectorForChildProcess(
ThreadProfiler::ThreadProfiler( ThreadProfiler::ThreadProfiler(
CallStackProfileParams::Thread thread, CallStackProfileParams::Thread thread,
scoped_refptr<base::SingleThreadTaskRunner> owning_thread_task_runner) scoped_refptr<base::SingleThreadTaskRunner> owning_thread_task_runner)
: owning_thread_task_runner_(owning_thread_task_runner), : thread_(thread),
periodic_profile_params_(GetProcess(), owning_thread_task_runner_(owning_thread_task_runner),
thread,
CallStackProfileParams::PERIODIC_COLLECTION),
weak_factory_(this) { weak_factory_(this) {
if (!StackSamplingConfiguration::Get()->IsProfilerEnabledForCurrentProcess()) if (!StackSamplingConfiguration::Get()->IsProfilerEnabledForCurrentProcess())
return; return;
std::unique_ptr<base::StackSamplingProfiler::ProfileBuilder> profile_builder;
// Enable the new profile builder 1% of the time.
if (base::RandInt(0, 99) == 0) {
profile_builder =
std::make_unique<CallStackProfileBuilder>(CallStackProfileParams(
GetProcess(), thread, CallStackProfileParams::PROCESS_STARTUP));
} else {
profile_builder =
std::make_unique<LegacyCallStackProfileBuilder>(CallStackProfileParams(
GetProcess(), thread, CallStackProfileParams::PROCESS_STARTUP));
}
startup_profiler_ = std::make_unique<StackSamplingProfiler>( startup_profiler_ = std::make_unique<StackSamplingProfiler>(
base::PlatformThread::CurrentId(), kSamplingParams, base::PlatformThread::CurrentId(), kSamplingParams,
std::move(profile_builder)); CreateProfileBuilder(CallStackProfileParams(
GetProcess(), thread, CallStackProfileParams::PROCESS_STARTUP)));
startup_profiler_->Start(); startup_profiler_->Start();
...@@ -256,14 +257,14 @@ void ThreadProfiler::ScheduleNextPeriodicCollection() { ...@@ -256,14 +257,14 @@ void ThreadProfiler::ScheduleNextPeriodicCollection() {
void ThreadProfiler::StartPeriodicSamplingCollection() { void ThreadProfiler::StartPeriodicSamplingCollection() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
// NB: Destroys the previous profiler as side effect. // NB: Destroys the previous profiler as side effect.
auto profile_builder = std::make_unique<LegacyCallStackProfileBuilder>(
periodic_profile_params_,
base::BindOnce(&ThreadProfiler::OnPeriodicCollectionCompleted,
owning_thread_task_runner_, weak_factory_.GetWeakPtr()));
periodic_profiler_ = std::make_unique<StackSamplingProfiler>( periodic_profiler_ = std::make_unique<StackSamplingProfiler>(
base::PlatformThread::CurrentId(), kSamplingParams, base::PlatformThread::CurrentId(), kSamplingParams,
std::move(profile_builder)); CreateProfileBuilder(
CallStackProfileParams(GetProcess(), thread_,
CallStackProfileParams::PERIODIC_COLLECTION),
base::BindOnce(&ThreadProfiler::OnPeriodicCollectionCompleted,
owning_thread_task_runner_,
weak_factory_.GetWeakPtr())));
periodic_profiler_->Start(); periodic_profiler_->Start();
} }
...@@ -110,9 +110,9 @@ class ThreadProfiler { ...@@ -110,9 +110,9 @@ class ThreadProfiler {
// Creates a new periodic profiler and initiates a collection with it. // Creates a new periodic profiler and initiates a collection with it.
void StartPeriodicSamplingCollection(); void StartPeriodicSamplingCollection();
scoped_refptr<base::SingleThreadTaskRunner> owning_thread_task_runner_; metrics::CallStackProfileParams::Thread thread_;
const metrics::CallStackProfileParams periodic_profile_params_; scoped_refptr<base::SingleThreadTaskRunner> owning_thread_task_runner_;
std::unique_ptr<base::StackSamplingProfiler> startup_profiler_; std::unique_ptr<base::StackSamplingProfiler> startup_profiler_;
......
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