Update method tracing to use per-thread buffer
Method tracing in streaming mode uses a global buffer to record method
entry / exit events and uses locks to synchronize across threads. Taking
a lock for each event is expensive and makes the method tracing slow.
This CL changes it to use a per-thread buffer so that each thread
accesses its own buffer. This also allows us to fast path method trace
events in JITed code in the future. The changes in this CL:
1. Add a per-thread buffer which is initialized lazily on the first
method trace event.
2. When the per-thread buffer is initialized we record the information
about the thread. This means we no longer need the bitmap we used
to record the thread info when a new thread is seen.
3. The data from the buffer is flushed to file:
1. When a thread detaches, so we can flush any recorded data
2. When the buffer is full
3. When we stop tracing.
The per-thread buffer is always accessed by the thread that owns it
except when we record the method enter events for on stack methods. It
is safe to access other thread's buffer since everything is suspended at
that point.
This CL also adds a test to check that the generated trace is in the
expected format.
Bug: 259258187
Test: art/testrunner.py -t 2246
Change-Id: I074bf2edb8c884dec0c9a7a9c37b4ef0ec7892a8
12 files changed