Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(756)

Unified Diff: base/profiler/stack_sampling_profiler.cc

Issue 2601633002: Use a common buffer across all instances for stack-copy. (Closed)
Patch Set: addressed review comments by wittman Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/profiler/native_stack_sampler_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/profiler/stack_sampling_profiler.cc
diff --git a/base/profiler/stack_sampling_profiler.cc b/base/profiler/stack_sampling_profiler.cc
index 0263a9f81af95b8d605e09c685d9fd21e9489bcb..76ad81df9e87968c4c8ab7fb0316aac44037cb3d 100644
--- a/base/profiler/stack_sampling_profiler.cc
+++ b/base/profiler/stack_sampling_profiler.cc
@@ -250,6 +250,11 @@ class StackSamplingProfiler::SamplingThread : public Thread {
// Thread:
void CleanUp() override;
+ // A stack-buffer used by the native sampler for its work. This buffer can
+ // be re-used for multiple native sampler objects so long as the API calls
+ // that take it are not called concurrently.
+ std::unique_ptr<NativeStackSampler::StackBuffer> stack_buffer_;
+
// A map of IDs to collection contexts. Because this class is a singleton
// that is never destroyed, context objects will never be destructed except
// by explicit action. Thus, it's acceptable to pass unretained pointers
@@ -421,6 +426,9 @@ StackSamplingProfiler::SamplingThread::GetOrCreateTaskRunnerForAdd() {
Stop();
}
+ DCHECK(!stack_buffer_);
+ stack_buffer_ = NativeStackSampler::CreateStackBuffer();
+
// The thread is not running. Start it and get associated runner. The task-
// runner has to be saved for future use because though it can be used from
// any thread, it can be acquired via task_runner() only on the created
@@ -517,12 +525,13 @@ void StackSamplingProfiler::SamplingThread::RecordSample(
// Record a single sample.
profile.samples.push_back(Sample());
- collection->native_sampler->RecordStackSample(&profile.samples.back());
+ collection->native_sampler->RecordStackSample(stack_buffer_.get(),
+ &profile.samples.back());
// If this is the last sample of a burst, record the total time.
if (collection->sample == collection->params.samples_per_burst - 1) {
profile.profile_duration = Time::Now() - collection->profile_start_time;
- collection->native_sampler->ProfileRecordingStopped();
+ collection->native_sampler->ProfileRecordingStopped(stack_buffer_.get());
}
}
@@ -647,6 +656,7 @@ void StackSamplingProfiler::SamplingThread::ShutdownTask(int add_events) {
// confusion.
thread_execution_state_ = EXITING;
thread_execution_state_task_runner_ = nullptr;
+ stack_buffer_.reset();
}
bool StackSamplingProfiler::SamplingThread::UpdateNextSampleTime(
« no previous file with comments | « base/profiler/native_stack_sampler_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698