Reduce overhead of Chrome's ETW tracing to make it more usable.
Reduce overhead of Chrome's ETW tracing to make it more usable.

When Chrome's ETW tracing is enabled it can consume more than half
of the total CPU time in the process, which means it is distorting
the results it is trying to measure. It also puts a lot of data into
the trace which cannot be viewed.

The biggest consumer of CPU time, by far, is AppendAsTraceFormat, which
consumes over 95% of the CPU time in TraceEventETWExport::AddEvent. Because
all categories are enabled this ends up creating many large buffers. The
cc::LayerTreeHostImpl events have been seen up to 22,500 bytes and
cc::Picture payloads have been seen up to 3,200,000 bytes! Ironically
the WPA trace viewer can't view payloads larger than 4094 bytes so all we
see for this effort and overhead is "Unable to parse data".

Truncating the payloads would let us see the partial data but would still
leave the distortion of execution time. The long-term solution is to
specify what categories are enabled in order to manage the volume of data.
Until then the prudent thing to do is to disable calls to AppendAsTraceFormat.

In addition, there is no reason for phase_string to be a std::string. This
overhead is relatively minor but measurable. It's worth fixing because the
fix is clean and simple.

The net effect is to drop the CPU overhead from 33-50% down to 1-7%.

This change makes Chrome's ETW tracing much more usable.

R=primiano@chromium.org
BUG=488257

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

Cr-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#329989}

axinging/chromium-crosswalk,axinging/chromium-crosswalk,hgl888/chromium-crosswalk,Fireblend/chromium-crosswalk,hgl888/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,Chilledheart/chromium,Pluto-tv/chromium-crosswalk,axinging/chromium-crosswalk,Chilledheart/chromium,Chilledheart/chromium,Chilledheart/chromium,Pluto-tv/chromium-crosswalk,chuan9/chromium-crosswalk,hgl888/chromium-crosswalk,Just-D/chromium-1,PeterWangIntel/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,chuan9/chromium-crosswalk,Fireblend/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,Chilledheart/chromium,Fireblend/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,hgl888/chromium-crosswalk,Chilledheart/chromium,chuan9/chromium-crosswalk,Fireblend/chromium-crosswalk,Fireblend/chromium-crosswalk,Pluto-tv/chromium-crosswalk,axinging/chromium-crosswalk,Just-D/chromium-1,axinging/chromium-crosswalk,Chilledheart/chromium,Just-D/chromium-1,chuan9/chromium-crosswalk,hgl888/chromium-crosswalk,chuan9/chromium-crosswalk,axinging/chromium-crosswalk,chuan9/chromium-crosswalk,Chilledheart/chromium,PeterWangIntel/chromium-crosswalk,axinging/chromium-crosswalk,Chilledheart/chromium,chuan9/chromium-crosswalk,Fireblend/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,hgl888/chromium-crosswalk,hgl888/chromium-crosswalk,axinging/chromium-crosswalk,Pluto-tv/chromium-crosswalk,Pluto-tv/chromium-crosswalk,hgl888/chromium-crosswalk,Just-D/chromium-1,Pluto-tv/chromium-crosswalk,chuan9/chromium-crosswalk,Pluto-tv/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,hgl888/chromium-crosswalk,Fireblend/chromium-crosswalk,axinging/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,axinging/chromium-crosswalk,Just-D/chromium-1,Fireblend/chromium-crosswalk,axinging/chromium-crosswalk,Just-D/chromium-1,PeterWangIntel/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,Just-D/chromium-1,Fireblend/chromium-crosswalk,Pluto-tv/chromium-crosswalk,Just-D/chromium-1,Pluto-tv/chromium-crosswalk,Just-D/chromium-1,TheTypoMaster/chromium-crosswalk,chuan9/chromium-crosswalk