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

Side by Side Diff: base/profiler/stack_sampling_profiler.cc

Issue 2530043002: Set process phases in the StackSamplingProfiler. (Closed)
Patch Set: improved comment Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/profiler/stack_sampling_profiler.h" 5 #include "base/profiler/stack_sampling_profiler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 return; 253 return;
254 } 254 }
255 } 255 }
256 256
257 void StackSamplingProfiler::SamplingThread::Stop() { 257 void StackSamplingProfiler::SamplingThread::Stop() {
258 stop_event_.Signal(); 258 stop_event_.Signal();
259 } 259 }
260 260
261 // StackSamplingProfiler ------------------------------------------------------ 261 // StackSamplingProfiler ------------------------------------------------------
262 262
263 subtle::Atomic32 StackSamplingProfiler::process_phases_ = 0; 263 subtle::Atomic32 StackSamplingProfiler::process_milestones_ = 0;
264 264
265 StackSamplingProfiler::SamplingParams::SamplingParams() 265 StackSamplingProfiler::SamplingParams::SamplingParams()
266 : initial_delay(TimeDelta::FromMilliseconds(0)), 266 : initial_delay(TimeDelta::FromMilliseconds(0)),
267 bursts(1), 267 bursts(1),
268 burst_interval(TimeDelta::FromMilliseconds(10000)), 268 burst_interval(TimeDelta::FromMilliseconds(10000)),
269 samples_per_burst(300), 269 samples_per_burst(300),
270 sampling_interval(TimeDelta::FromMilliseconds(100)) { 270 sampling_interval(TimeDelta::FromMilliseconds(100)) {
271 } 271 }
272 272
273 StackSamplingProfiler::StackSamplingProfiler( 273 StackSamplingProfiler::StackSamplingProfiler(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 &sampling_thread_handle_)) 316 &sampling_thread_handle_))
317 sampling_thread_.reset(); 317 sampling_thread_.reset();
318 } 318 }
319 319
320 void StackSamplingProfiler::Stop() { 320 void StackSamplingProfiler::Stop() {
321 if (sampling_thread_) 321 if (sampling_thread_)
322 sampling_thread_->Stop(); 322 sampling_thread_->Stop();
323 } 323 }
324 324
325 // static 325 // static
326 void StackSamplingProfiler::SetProcessPhase(int phase) { 326 void StackSamplingProfiler::SetProcessMilestone(int milestone) {
327 DCHECK_LE(0, phase); 327 DCHECK_LE(0, milestone);
328 DCHECK_GT(static_cast<int>(sizeof(process_phases_) * 8), phase); 328 DCHECK_GT(static_cast<int>(sizeof(process_milestones_) * 8), milestone);
329 DCHECK_EQ(0, subtle::NoBarrier_Load(&process_phases_) & (1 << phase)); 329 DCHECK_EQ(0, subtle::NoBarrier_Load(&process_milestones_) & (1 << milestone));
330 ChangeAtomicFlags(&process_phases_, 1 << phase, 0); 330 ChangeAtomicFlags(&process_milestones_, 1 << milestone, 0);
331 } 331 }
332 332
333 // static 333 // static
334 void StackSamplingProfiler::ResetAnnotationsForTesting() { 334 void StackSamplingProfiler::ResetAnnotationsForTesting() {
335 subtle::NoBarrier_Store(&process_phases_, 0u); 335 subtle::NoBarrier_Store(&process_milestones_, 0u);
336 } 336 }
337 337
338 // static 338 // static
339 void StackSamplingProfiler::RecordAnnotations(Sample* sample) { 339 void StackSamplingProfiler::RecordAnnotations(Sample* sample) {
340 // The code inside this method must not do anything that could acquire a 340 // The code inside this method must not do anything that could acquire a
341 // mutex, including allocating memory (which includes LOG messages) because 341 // mutex, including allocating memory (which includes LOG messages) because
342 // that mutex could be held by a stopped thread, thus resulting in deadlock. 342 // that mutex could be held by a stopped thread, thus resulting in deadlock.
343 sample->process_phases = subtle::NoBarrier_Load(&process_phases_); 343 sample->process_milestones = subtle::NoBarrier_Load(&process_milestones_);
344 } 344 }
345 345
346 // StackSamplingProfiler::Frame global functions ------------------------------ 346 // StackSamplingProfiler::Frame global functions ------------------------------
347 347
348 bool operator==(const StackSamplingProfiler::Module& a, 348 bool operator==(const StackSamplingProfiler::Module& a,
349 const StackSamplingProfiler::Module& b) { 349 const StackSamplingProfiler::Module& b) {
350 return a.base_address == b.base_address && a.id == b.id && 350 return a.base_address == b.base_address && a.id == b.id &&
351 a.filename == b.filename; 351 a.filename == b.filename;
352 } 352 }
353 353
354 bool operator==(const StackSamplingProfiler::Sample& a, 354 bool operator==(const StackSamplingProfiler::Sample& a,
355 const StackSamplingProfiler::Sample& b) { 355 const StackSamplingProfiler::Sample& b) {
356 return a.process_phases == b.process_phases && a.frames == b.frames; 356 return a.process_milestones == b.process_milestones && a.frames == b.frames;
357 } 357 }
358 358
359 bool operator!=(const StackSamplingProfiler::Sample& a, 359 bool operator!=(const StackSamplingProfiler::Sample& a,
360 const StackSamplingProfiler::Sample& b) { 360 const StackSamplingProfiler::Sample& b) {
361 return !(a == b); 361 return !(a == b);
362 } 362 }
363 363
364 bool operator<(const StackSamplingProfiler::Sample& a, 364 bool operator<(const StackSamplingProfiler::Sample& a,
365 const StackSamplingProfiler::Sample& b) { 365 const StackSamplingProfiler::Sample& b) {
366 if (a.process_phases < b.process_phases) 366 if (a.process_milestones < b.process_milestones)
367 return true; 367 return true;
368 if (a.process_phases > b.process_phases) 368 if (a.process_milestones > b.process_milestones)
369 return false; 369 return false;
370 370
371 return a.frames < b.frames; 371 return a.frames < b.frames;
372 } 372 }
373 373
374 bool operator==(const StackSamplingProfiler::Frame &a, 374 bool operator==(const StackSamplingProfiler::Frame &a,
375 const StackSamplingProfiler::Frame &b) { 375 const StackSamplingProfiler::Frame &b) {
376 return a.instruction_pointer == b.instruction_pointer && 376 return a.instruction_pointer == b.instruction_pointer &&
377 a.module_index == b.module_index; 377 a.module_index == b.module_index;
378 } 378 }
379 379
380 bool operator<(const StackSamplingProfiler::Frame &a, 380 bool operator<(const StackSamplingProfiler::Frame &a,
381 const StackSamplingProfiler::Frame &b) { 381 const StackSamplingProfiler::Frame &b) {
382 return (a.module_index < b.module_index) || 382 return (a.module_index < b.module_index) ||
383 (a.module_index == b.module_index && 383 (a.module_index == b.module_index &&
384 a.instruction_pointer < b.instruction_pointer); 384 a.instruction_pointer < b.instruction_pointer);
385 } 385 }
386 386
387 } // namespace base 387 } // namespace base
OLDNEW
« no previous file with comments | « base/profiler/stack_sampling_profiler.h ('k') | base/profiler/stack_sampling_profiler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698