tree: 0b64a8d7ed2a3396b6995ef34409779f2aa741e3 [path history] [tgz]
  1. chrome_unwind_info_android.cc
  2. chrome_unwind_info_android.h
  3. chrome_unwind_info_android_unittest.cc
  4. chrome_unwinder_android.cc
  5. chrome_unwinder_android.h
  6. chrome_unwinder_android_unittest.cc
  7. frame.cc
  8. frame.h
  9. frame_pointer_unwinder.cc
  10. frame_pointer_unwinder.h
  11. frame_pointer_unwinder_unittest.cc
  12. libunwindstack_unwinder_android.cc
  13. libunwindstack_unwinder_android.h
  14. libunwindstack_unwinder_android_unittest.cc
  15. metadata_recorder.cc
  16. metadata_recorder.h
  17. metadata_recorder_unittest.cc
  18. module_cache.cc
  19. module_cache.h
  20. module_cache_mac.cc
  21. module_cache_posix.cc
  22. module_cache_starboard.cc
  23. module_cache_unittest.cc
  24. module_cache_win.cc
  25. native_unwinder_android.cc
  26. native_unwinder_android.h
  27. native_unwinder_android_map_delegate.h
  28. native_unwinder_android_memory_regions_map.h
  29. native_unwinder_android_unittest.cc
  30. native_unwinder_win.cc
  31. native_unwinder_win.h
  32. OWNERS
  33. profile_builder.h
  34. README.md
  35. register_context.h
  36. sample_metadata.cc
  37. sample_metadata.h
  38. sample_metadata_unittest.cc
  39. sampling_profiler_thread_token.cc
  40. sampling_profiler_thread_token.h
  41. stack_base_address_posix.cc
  42. stack_base_address_posix.h
  43. stack_base_address_posix_unittest.cc
  44. stack_buffer.cc
  45. stack_buffer.h
  46. stack_buffer_unittest.cc
  47. stack_copier.cc
  48. stack_copier.h
  49. stack_copier_signal.cc
  50. stack_copier_signal.h
  51. stack_copier_signal_unittest.cc
  52. stack_copier_suspend.cc
  53. stack_copier_suspend.h
  54. stack_copier_suspend_unittest.cc
  55. stack_copier_unittest.cc
  56. stack_sampler.cc
  57. stack_sampler.h
  58. stack_sampler_android.cc
  59. stack_sampler_ios.cc
  60. stack_sampler_mac.cc
  61. stack_sampler_posix.cc
  62. stack_sampler_starboard.cc
  63. stack_sampler_unittest.cc
  64. stack_sampler_win.cc
  65. stack_sampling_profiler.cc
  66. stack_sampling_profiler.h
  67. stack_sampling_profiler_java_test_util.cc
  68. stack_sampling_profiler_java_test_util.h
  69. stack_sampling_profiler_test_util.cc
  70. stack_sampling_profiler_test_util.h
  71. stack_sampling_profiler_unittest.cc
  72. suspendable_thread_delegate.h
  73. suspendable_thread_delegate_mac.cc
  74. suspendable_thread_delegate_mac.h
  75. suspendable_thread_delegate_win.cc
  76. suspendable_thread_delegate_win.h
  77. test_support_library.cc
  78. thread_delegate.h
  79. thread_delegate_posix.cc
  80. thread_delegate_posix.h
  81. thread_delegate_posix_unittest.cc
  82. unwinder.cc
  83. unwinder.h
  84. win32_stack_frame_unwinder.cc
  85. win32_stack_frame_unwinder.h
  86. win32_stack_frame_unwinder_unittest.cc
base/profiler/README.md

What is this?

//base/profiler implements a statistical profiler for Chrome execution. It supports periodic sampling of thread stacks for the purpose of understanding how frequently different parts of the Chrome code are being executed. The profiler is used to collect execution information by UMA, for broad-scale profiling, and by Chrometto, for targeted profiling during tracing.

Technical Overview

The primary entry point to this code is StackSamplingProfiler. This class regularly records the list of currently executing functions on a target thread. See the comments above that function for an overview of how to use the profiler.

The details are very platform-specific, but the major sub-components are

  • A dedicated thread is created to periodically wake up and sample the target thread. At each wake up:
    • A StackCopier copies the target thread's stack memory into a StackBuffer.
    • One or more Unwinders take the memory blob in the StackBuffer and turn it into a list of function Frames. Every platform has a native unwinder to deal with C++ frames; there are also unwinders for V8's special frame layout and for Java frames.
    • Frames have the function instruction address and some module information from ModuleCache. This should be enough for a program with access to the original debug information to reconstruct the names of the functions in the stack. The actual conversion back to human-readable names is not part of this directory's code.
    • A subclass of ProfileBuilder is called with a vector of Frames corresponding to one stack. The various users of this code are responsible for implementing this subclass and recording the stacks in the manner they see fit.