tree: a0d721bb6e4c1d2de948e60854f413c15b5d85c2 [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. DIR_METADATA
  8. frame.cc
  9. frame.h
  10. frame_pointer_unwinder.cc
  11. frame_pointer_unwinder.h
  12. frame_pointer_unwinder_unittest.cc
  13. libunwindstack_unwinder_android.cc
  14. libunwindstack_unwinder_android.h
  15. libunwindstack_unwinder_android_unittest.cc
  16. metadata_recorder.cc
  17. metadata_recorder.h
  18. metadata_recorder_unittest.cc
  19. module_cache.cc
  20. module_cache.h
  21. module_cache_apple.cc
  22. module_cache_posix.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_memory_regions_map_impl.cc
  30. native_unwinder_android_memory_regions_map_impl.h
  31. native_unwinder_android_unittest.cc
  32. native_unwinder_win.cc
  33. native_unwinder_win.h
  34. OWNERS
  35. profile_builder.h
  36. README.md
  37. register_context.h
  38. sample_metadata.cc
  39. sample_metadata.h
  40. sample_metadata_unittest.cc
  41. sampling_profiler_thread_token.cc
  42. sampling_profiler_thread_token.h
  43. stack_base_address_posix.cc
  44. stack_base_address_posix.h
  45. stack_base_address_posix_unittest.cc
  46. stack_buffer.cc
  47. stack_buffer.h
  48. stack_buffer_unittest.cc
  49. stack_copier.cc
  50. stack_copier.h
  51. stack_copier_signal.cc
  52. stack_copier_signal.h
  53. stack_copier_signal_unittest.cc
  54. stack_copier_suspend.cc
  55. stack_copier_suspend.h
  56. stack_copier_suspend_unittest.cc
  57. stack_copier_unittest.cc
  58. stack_sampler.cc
  59. stack_sampler.h
  60. stack_sampler_android.cc
  61. stack_sampler_ios.cc
  62. stack_sampler_mac.cc
  63. stack_sampler_posix.cc
  64. stack_sampler_unittest.cc
  65. stack_sampler_win.cc
  66. stack_sampling_profiler.cc
  67. stack_sampling_profiler.h
  68. stack_sampling_profiler_java_test_util.cc
  69. stack_sampling_profiler_java_test_util.h
  70. stack_sampling_profiler_test_util.cc
  71. stack_sampling_profiler_test_util.h
  72. stack_sampling_profiler_unittest.cc
  73. suspendable_thread_delegate.h
  74. suspendable_thread_delegate_mac.cc
  75. suspendable_thread_delegate_mac.h
  76. suspendable_thread_delegate_win.cc
  77. suspendable_thread_delegate_win.h
  78. test_support_library.cc
  79. thread_delegate.h
  80. thread_delegate_posix.cc
  81. thread_delegate_posix.h
  82. thread_delegate_posix_unittest.cc
  83. unwinder.cc
  84. unwinder.h
  85. win32_stack_frame_unwinder.cc
  86. win32_stack_frame_unwinder.h
  87. 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.