Commit aa4df68b authored by Charlie Andrews's avatar Charlie Andrews Committed by Commit Bot

Create a process-global MetadataRecorder for the stack sampling profiler

This paves the way for Chromium code to manipulate the metadata
recorder and help provide the stack sampling profiler with context
about what's happening when a sample is taken.

Bug: 913570
Change-Id: I96d7bcc2f4872467852042495c0fdf1ad5d8c4cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1572370
Commit-Queue: Charlie Andrews <charliea@chromium.org>
Commit-Queue: Mike Wittman <wittman@chromium.org>
Reviewed-by: default avatarMike Wittman <wittman@chromium.org>
Auto-Submit: Charlie Andrews <charliea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652161}
parent 1bb65c1d
...@@ -234,7 +234,9 @@ ThreadProfiler::ThreadProfiler( ...@@ -234,7 +234,9 @@ ThreadProfiler::ThreadProfiler(
std::make_unique<CallStackProfileBuilder>( std::make_unique<CallStackProfileBuilder>(
CallStackProfileParams(GetProcess(), thread, CallStackProfileParams(GetProcess(), thread,
CallStackProfileParams::PROCESS_STARTUP), CallStackProfileParams::PROCESS_STARTUP),
work_id_recorder_.get())); work_id_recorder_.get(),
&metrics::CallStackProfileBuilder::
GetStackSamplingProfilerMetadataRecorder()));
startup_profiler_->Start(); startup_profiler_->Start();
...@@ -280,7 +282,9 @@ void ThreadProfiler::StartPeriodicSamplingCollection() { ...@@ -280,7 +282,9 @@ void ThreadProfiler::StartPeriodicSamplingCollection() {
std::make_unique<CallStackProfileBuilder>( std::make_unique<CallStackProfileBuilder>(
CallStackProfileParams(GetProcess(), thread_, CallStackProfileParams(GetProcess(), thread_,
CallStackProfileParams::PERIODIC_COLLECTION), CallStackProfileParams::PERIODIC_COLLECTION),
work_id_recorder_.get(), nullptr, work_id_recorder_.get(),
&metrics::CallStackProfileBuilder::
GetStackSamplingProfilerMetadataRecorder(),
base::BindOnce(&ThreadProfiler::OnPeriodicCollectionCompleted, base::BindOnce(&ThreadProfiler::OnPeriodicCollectionCompleted,
owning_thread_task_runner_, owning_thread_task_runner_,
weak_factory_.GetWeakPtr()))); weak_factory_.GetWeakPtr())));
......
...@@ -200,6 +200,13 @@ void CallStackProfileBuilder::SetParentProfileCollectorForChildProcess( ...@@ -200,6 +200,13 @@ void CallStackProfileBuilder::SetParentProfileCollectorForChildProcess(
std::move(browser_interface)); std::move(browser_interface));
} }
// static
MetadataRecorder&
CallStackProfileBuilder::GetStackSamplingProfilerMetadataRecorder() {
static base::NoDestructor<MetadataRecorder> instance;
return *instance;
}
void CallStackProfileBuilder::PassProfilesToMetricsProvider( void CallStackProfileBuilder::PassProfilesToMetricsProvider(
SampledProfile sampled_profile) { SampledProfile sampled_profile) {
if (sampled_profile.process() == BROWSER_PROCESS) { if (sampled_profile.process() == BROWSER_PROCESS) {
......
...@@ -81,6 +81,10 @@ class CallStackProfileBuilder : public base::ProfileBuilder { ...@@ -81,6 +81,10 @@ class CallStackProfileBuilder : public base::ProfileBuilder {
static void SetParentProfileCollectorForChildProcess( static void SetParentProfileCollectorForChildProcess(
metrics::mojom::CallStackProfileCollectorPtr browser_interface); metrics::mojom::CallStackProfileCollectorPtr browser_interface);
// Returns the process-global metadata recorder instance used for tracking
// sampling profiler metadata.
static MetadataRecorder& GetStackSamplingProfilerMetadataRecorder();
protected: protected:
// Test seam. // Test seam.
virtual void PassProfilesToMetricsProvider(SampledProfile sampled_profile); virtual void PassProfilesToMetricsProvider(SampledProfile sampled_profile);
......
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