[base tracing] Move message pump trace events to disabled-by-default-base

These events are useful in some traces but are so high frequency that
they fill up the trace buffer too much for generic scenarios.

The only event kept is DispatchMessage as this is the native equivalent
of RunTask. Moved it to after ProcessPumpReplacementMessage() to avoid
a double-event when the first ProcessMessageHelper() processes
kMsgHaveWork and recursively invokes itself.

R=etienneb@chromium.org, fdoray@chromium.org

Bug: 899897
Change-Id: I6895789fcbb15308892a9ab9f8e9ac62ba7b617f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2845112
Commit-Queue: Gabriel Charette <gab@chromium.org>
Commit-Queue: Etienne Bergeron <etienneb@chromium.org>
Reviewed-by: Etienne Bergeron <etienneb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#875468}
GitOrigin-RevId: ea30813f5e93ab6d15385f0860795dd5b65f93ef
2 files changed
tree: ccf6be1af589bd970cb7b4dfac61c8b5e75e166e
  1. allocator/
  2. android/
  3. containers/
  4. debug/
  5. files/
  6. fuchsia/
  7. functional/
  8. hash/
  9. i18n/
  10. ios/
  11. json/
  12. mac/
  13. memory/
  14. message_loop/
  15. metrics/
  16. nix/
  17. numerics/
  18. posix/
  19. power_monitor/
  20. process/
  21. profiler/
  22. ranges/
  23. sampling_heap_profiler/
  24. strings/
  25. synchronization/
  26. system/
  27. task/
  28. test/
  29. third_party/
  30. threading/
  31. time/
  32. timer/
  33. trace_event/
  34. tracing/
  35. types/
  36. util/
  37. win/
  38. as_const.h
  39. as_const_unittest.cc
  40. at_exit.cc
  41. at_exit.h
  42. at_exit_unittest.cc
  43. atomic_ref_count.h
  44. atomic_sequence_num.h
  45. atomicops.h
  46. atomicops_internals_atomicword_compat.h
  47. atomicops_internals_portable.h
  48. atomicops_unittest.cc
  49. auto_reset.h
  50. auto_reset_unittest.cc
  51. barrier_closure.cc
  52. barrier_closure.h
  53. barrier_closure_unittest.cc
  54. base64.cc
  55. base64.h
  56. base64_decode_fuzzer.cc
  57. base64_encode_fuzzer.cc
  58. base64_unittest.cc
  59. base64url.cc
  60. base64url.h
  61. base64url_unittest.cc
  62. base_export.h
  63. base_paths.cc
  64. base_paths.h
  65. base_paths_android.cc
  66. base_paths_android.h
  67. base_paths_fuchsia.cc
  68. base_paths_fuchsia.h
  69. base_paths_mac.h
  70. base_paths_mac.mm
  71. base_paths_posix.cc
  72. base_paths_posix.h
  73. base_paths_win.cc
  74. base_paths_win.h
  75. base_switches.cc
  76. base_switches.h
  77. big_endian.cc
  78. big_endian.h
  79. big_endian_unittest.cc
  80. bind.h
  81. bind_internal.h
  82. bind_post_task.h
  83. bind_post_task_internal.h
  84. bind_post_task_unittest.cc
  85. bind_post_task_unittest.nc
  86. bind_unittest.cc
  87. bind_unittest.nc
  88. bit_cast.h
  89. bit_cast_unittest.cc
  90. bits.h
  91. bits_unittest.cc
  92. BUILD.gn
  93. build_time.cc
  94. build_time.h
  95. build_time_unittest.cc
  96. callback.h
  97. callback_forward.h
  98. callback_helpers.cc
  99. callback_helpers.h
  100. callback_helpers_unittest.cc
  101. callback_internal.cc
  102. callback_internal.h
  103. callback_list.cc
  104. callback_list.h
  105. callback_list_unittest.cc
  106. callback_list_unittest.nc
  107. callback_unittest.cc
  108. callback_unittest.nc
  109. cancelable_callback.h
  110. cancelable_callback_unittest.cc
  111. check.cc
  112. check.h
  113. check_example.cc
  114. check_op.cc
  115. check_op.h
  116. check_unittest.cc
  117. command_line.cc
  118. command_line.h
  119. command_line_unittest.cc
  120. compiler_specific.h
  121. component_export.h
  122. component_export_unittest.cc
  123. cpu.cc
  124. cpu.h
  125. cpu_affinity_posix.cc
  126. cpu_affinity_posix.h
  127. cpu_affinity_posix_unittest.cc
  128. cpu_unittest.cc
  129. critical_closure.h
  130. critical_closure_internal_ios.mm
  131. dcheck_is_on.h
  132. deferred_sequenced_task_runner.cc
  133. deferred_sequenced_task_runner.h
  134. deferred_sequenced_task_runner_unittest.cc
  135. DEPS
  136. DIR_METADATA
  137. enterprise_util.h
  138. enterprise_util_mac.mm
  139. enterprise_util_mac_unittest.mm
  140. enterprise_util_win.cc
  141. environment.cc
  142. environment.h
  143. environment_unittest.cc
  144. export_template.h
  145. feature_list.cc
  146. feature_list.h
  147. feature_list_unittest.cc
  148. file_descriptor_posix.h
  149. file_descriptor_store.cc
  150. file_descriptor_store.h
  151. file_version_info.h
  152. file_version_info_mac.h
  153. file_version_info_mac.mm
  154. file_version_info_win.cc
  155. file_version_info_win.h
  156. file_version_info_win_unittest.cc
  157. format_macros.h
  158. gmock_unittest.cc
  159. gtest_prod_util.h
  160. guid.cc
  161. guid.h
  162. guid_unittest.cc
  163. immediate_crash.h
  164. immediate_crash_unittest.cc
  165. lazy_instance.h
  166. lazy_instance_helpers.cc
  167. lazy_instance_helpers.h
  168. lazy_instance_unittest.cc
  169. linux_util.cc
  170. linux_util.h
  171. linux_util_unittest.cc
  172. location.cc
  173. location.h
  174. location_unittest.cc
  175. logging.cc
  176. logging.h
  177. logging_chromeos.cc
  178. logging_unittest.cc
  179. logging_win.cc
  180. logging_win.h
  181. macros.h
  182. native_library.cc
  183. native_library.h
  184. native_library_fuchsia.cc
  185. native_library_ios.mm
  186. native_library_mac.mm
  187. native_library_posix.cc
  188. native_library_unittest.cc
  189. native_library_win.cc
  190. no_destructor.h
  191. no_destructor_unittest.cc
  192. notreached.cc
  193. notreached.h
  194. observer_list.h
  195. observer_list_internal.cc
  196. observer_list_internal.h
  197. observer_list_perftest.cc
  198. observer_list_threadsafe.cc
  199. observer_list_threadsafe.h
  200. observer_list_threadsafe_unittest.cc
  201. observer_list_types.cc
  202. observer_list_types.h
  203. observer_list_unittest.cc
  204. observer_list_unittest.nc
  205. one_shot_event.cc
  206. one_shot_event.h
  207. one_shot_event_unittest.cc
  208. optional.h
  209. optional_unittest.cc
  210. optional_unittest.nc
  211. os_compat_android.cc
  212. os_compat_android.h
  213. os_compat_android_unittest.cc
  214. os_compat_nacl.cc
  215. os_compat_nacl.h
  216. OWNERS
  217. parameter_pack.h
  218. parameter_pack_unittest.cc
  219. path_service.cc
  220. path_service.h
  221. path_service_unittest.cc
  222. pending_task.cc
  223. pending_task.h
  224. pickle.cc
  225. pickle.h
  226. pickle_fuzzer.cc
  227. pickle_unittest.cc
  228. post_task_and_reply_with_result_internal.h
  229. PRESUBMIT.py
  230. rand_util.cc
  231. rand_util.h
  232. rand_util_fuchsia.cc
  233. rand_util_nacl.cc
  234. rand_util_posix.cc
  235. rand_util_unittest.cc
  236. rand_util_win.cc
  237. README.md
  238. run_loop.cc
  239. run_loop.h
  240. run_loop_unittest.cc
  241. safe_numerics_unittest.cc
  242. scoped_clear_last_error.h
  243. scoped_clear_last_error_unittest.cc
  244. scoped_clear_last_error_win.cc
  245. scoped_generic.h
  246. scoped_generic_unittest.cc
  247. scoped_multi_source_observation.h
  248. scoped_multi_source_observation_unittest.cc
  249. scoped_native_library.cc
  250. scoped_native_library.h
  251. scoped_native_library_unittest.cc
  252. scoped_observation.h
  253. scoped_observation_unittest.cc
  254. scoped_observer.h
  255. SECURITY_OWNERS
  256. security_unittest.cc
  257. sequence_checker.h
  258. sequence_checker_impl.cc
  259. sequence_checker_impl.h
  260. sequence_checker_unittest.cc
  261. sequence_checker_unittest.nc
  262. sequence_token.cc
  263. sequence_token.h
  264. sequence_token_unittest.cc
  265. sequenced_task_runner.cc
  266. sequenced_task_runner.h
  267. sequenced_task_runner_helpers.h
  268. sequenced_task_runner_unittest.cc
  269. single_thread_task_runner.h
  270. stl_util.h
  271. stl_util_unittest.cc
  272. supports_user_data.cc
  273. supports_user_data.h
  274. supports_user_data_unittest.cc
  275. sync_socket.cc
  276. sync_socket.h
  277. sync_socket_nacl.cc
  278. sync_socket_posix.cc
  279. sync_socket_unittest.cc
  280. sync_socket_win.cc
  281. sys_byteorder.h
  282. sys_byteorder_unittest.cc
  283. syslog_logging.cc
  284. syslog_logging.h
  285. task_runner.cc
  286. task_runner.h
  287. task_runner_unittest.cc
  288. task_runner_util.h
  289. task_runner_util_unittest.cc
  290. template_util.h
  291. template_util_unittest.cc
  292. thread_annotations.h
  293. thread_annotations_unittest.cc
  294. thread_annotations_unittest.nc
  295. token.cc
  296. token.h
  297. token_unittest.cc
  298. tools_sanity_unittest.cc
  299. traits_bag.h
  300. traits_bag_unittest.cc
  301. traits_bag_unittest.nc
  302. tuple.h
  303. tuple_unittest.cc
  304. unguessable_token.cc
  305. unguessable_token.h
  306. unguessable_token_unittest.cc
  307. updateable_sequenced_task_runner.h
  308. value_iterators.cc
  309. value_iterators.h
  310. value_iterators_unittest.cc
  311. values.cc
  312. values.h
  313. values_unittest.cc
  314. version.cc
  315. version.h
  316. version_unittest.cc
  317. vlog.cc
  318. vlog.h
  319. vlog_unittest.cc
README.md

What is this

Contains a written down set of principles and other information on //base. Please add to it!

About //base:

Chromium is a very mature project. Most things that are generally useful are already here and things not here aren't generally useful.

The bar for adding stuff to base is that it must have demonstrated wide applicability. Prefer to add things closer to where they're used (i.e. “not base”), and pull into base only when needed. In a project our size, sometimes even duplication is OK and inevitable.

Adding a new logging macro DPVELOG_NE is not more clear than just writing the stuff you want to log in a regular logging statement, even if it makes your calling code longer. Just add it to your own code.

If the code in question does not need to be used inside base, but will have multiple consumers across the codebase, consider placing it in a new directory under components/ instead.

base is written for the Chromium project and is not intended to be used outside it. Using base outside of src.git is explicitly not supported, and base makes no guarantees about API (or even ABI) stability (like all other code in Chromium). New code that depends on base/ must be in src.git. Code that's not in src.git but pulled in through DEPS (for example, v8) cannot use base.

Qualifications for being in //base OWNERS

  • interest and ability to learn low level/high detail/complex c++ stuff
  • inclination to always ask why and understand everything (including external interactions like win32) rather than just hoping the author did it right
  • mentorship/experience
  • demonstrated good judgement (esp with regards to public APIs) over a length of time

Owners are added when a contributor has shown the above qualifications and when they express interest. There isn't an upper bound on the number of OWNERS.

Design and naming

  • Be sure to use the base namespace.
  • STL-like constructs should adhere as closely to STL as possible. Functions and behaviors not present in STL should only be added when they are related to the specific data structure implemented by the container.
  • For STL-like constructs our policy is that they should use STL-like naming even when it may conflict with the style guide. So functions and class names should be lower case with underscores. Non-STL-like classes and functions should use Google naming.

Performance testing

Since the primitives provided by //base are used very widely, it is important to ensure they scale to the necessary workloads and perform well under all supported platforms. The base_perftests target is a suite of synthetic microbenchmarks that measure performance in various scenarios:

  • BasicPostTaskPerfTest: Exercises MessageLoopTaskRunner's multi-threaded queue in isolation.
  • ConditionVariablePerfTest: Measures thread switching cost of condition variables.
  • IntegratedPostTaskPerfTest: Exercises the full MessageLoop/RunLoop machinery.
  • JSONPerfTest: Tests JSONWriter and JSONReader performance.
  • MessageLoopPerfTest: Measures the speed of task posting in various configurations.
  • ObserverListPerfTest: Exercises adding, removing and signalling observers.
  • PthreadEventPerfTest: Establishes the baseline thread switching cost using pthreads.
  • ScheduleWorkTest: Measures the overhead of MessagePump::ScheduleWork.
  • SequenceManagerPerfTest: Benchmarks SequenceManager scheduling with various underlying task runners.
  • TaskObserverPerfTest: Measures the incremental cost of adding task observers.
  • TaskPerfTest: Checks the cost of posting tasks between threads.
  • WaitableEvent{Thread,}PerfTest: Measures waitable events in single and multithreaded scenarios.

Regressions in these benchmarks can generally by caused by 1) operating system changes, 2) compiler version or flag changes or 3) changes in //base code itself.