DescriptionThread-local trace-event buffers
Previously we use a central trace-event buffer to store trace events
from all threads, which needs a lock. Measurement showed that on
Android the lock contributes over 50% of the total overhead of
trace event.
Use thread-local trace-event buffers so that in most times trace
events can be handled lock-free.
TraceLog::Flush() now may asynchronously call the callback.
TODO: Now for a message loop running a blocking task, async flush
doesn't work. The async flush will timeout and finish without
collecting the last batch of such thread if any.
On Nexus 4 this patch can reduce the average overhead of trace_event
from 15~20us to about 5~8us for a busy app. Note the numbers are not
very accurate because
- the time tick seems 30us on Android. The average number may be just
a result of increased percentage of trace events whose overhead < 30us.
- there are differences in the measurement method of the overhead
because of the change of the code structure.
BUG=264667
TEST=Updated existing tests: TraceEventTestFixture.DataCapturedOnThread
and TraceEventTestFixture.DataCapturedManyThreads. Existing unit/browser
tests using trace_event should still pass.
R=nduca, dsinclair
TBR=phajdan.jr (for base/test/trace_event_analyzer_unittest.cc)
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=221766
Patch Set 1 : #
Total comments: 8
Patch Set 2 : #
Total comments: 18
Patch Set 3 : #
Total comments: 9
Patch Set 4 : THREAD_LOCAL_BUFFERS as an option; Tests still missing #Patch Set 5 : #Patch Set 6 : #
Total comments: 24
Patch Set 7 : #Patch Set 8 : Thread flush timeout; Shrink thread-local buffer size #Patch Set 9 : Update browser_shutdown_profile_dumper #Messages
Total messages: 30 (0 generated)
|