[tracing] Add infrastructure to account memory overhead of tracing.
commit2a65cfecf41fb3dec2c0f5c48f0a647d9a5524c0
authorprimiano <primiano@chromium.org>
Thu, 11 Jun 2015 00:43:15 +0000 (10 17:43 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 11 Jun 2015 00:43:38 +0000 (11 00:43 +0000)
treefa651a1c37671d18f63053a86c9ab0931533c2f6
parentf1a2fb87244f7005bc50372b63fa2ba063d50082
[tracing] Add infrastructure to account memory overhead of tracing.

Tracing uses memory for the trace log and for the refptr objects
that can be attached to the trace events (Convertable and friends).
This means that when enabling memory-infra tracing will measure also
its own memory that would not have been there if tracing was disabled
in the first place.
In order to mitigate this problem, this CL:
 - Introduces EstimateTraceMemoryOverhead() method to the trace classes
   to get a rough estimation of themselves.
 - Adds a dumper for the general trace log + a dumper for each
   thread-local event buffer.
 - When invoked these dumpers dump the memory used by tracing itself to the
   trace.
 - The tracing dumpers produce a breakdown by object number and size.
   This makes it much easier to recalibrate the self-accounting by
   comparing the tracing numbers with external tools (e.g.,
   Instruments on Mac).

This change should not affect the behvavior / performance of tracing when
memory-infra is not enabled. The OnMemoryDump methods, then, will not be
called.

BUG=495628

Review URL: https://codereview.chromium.org/1148983011

Cr-Commit-Position: refs/heads/master@{#333862}
base/trace_event/BUILD.gn
base/trace_event/memory_dump_manager.cc
base/trace_event/trace_event.gypi
base/trace_event/trace_event_argument.cc
base/trace_event/trace_event_argument.h
base/trace_event/trace_event_impl.cc
base/trace_event/trace_event_impl.h
base/trace_event/trace_event_memory_overhead.cc [new file with mode: 0644]
base/trace_event/trace_event_memory_overhead.h [new file with mode: 0644]