summaryrefslogtreecommitdiff
path: root/runtime/entrypoints_order_test.cc
diff options
context:
space:
mode:
author Mythri Alle <mythria@google.com> 2022-12-06 14:44:09 +0000
committer Mythri Alle <mythria@google.com> 2022-12-15 09:21:16 +0000
commit887fad3da55b232205d2272216b2a9a7cd253659 (patch)
treebc85e22755a418aaddb17f9ff1b33e8d8af19878 /runtime/entrypoints_order_test.cc
parent1deea776a23e6119c7b790f749f1b7d2b0bdc02e (diff)
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
Diffstat (limited to 'runtime/entrypoints_order_test.cc')
-rw-r--r--runtime/entrypoints_order_test.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/runtime/entrypoints_order_test.cc b/runtime/entrypoints_order_test.cc
index bd822c1530..50fa0ab0fb 100644
--- a/runtime/entrypoints_order_test.cc
+++ b/runtime/entrypoints_order_test.cc
@@ -135,10 +135,14 @@ class EntrypointsOrderTest : public CommonArtTest {
EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, thread_local_mark_stack, async_exception, sizeof(void*));
EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, async_exception, top_reflective_handle_scope,
sizeof(void*));
+ EXPECT_OFFSET_DIFFP(
+ Thread, tlsPtr_, top_reflective_handle_scope, method_trace_buffer, sizeof(void*));
+ EXPECT_OFFSET_DIFFP(
+ Thread, tlsPtr_, method_trace_buffer, method_trace_buffer_index, sizeof(void*));
// The first field after tlsPtr_ is forced to a 16 byte alignment so it might have some space.
auto offset_tlsptr_end = OFFSETOF_MEMBER(Thread, tlsPtr_) +
sizeof(decltype(reinterpret_cast<Thread*>(16)->tlsPtr_));
- CHECKED(offset_tlsptr_end - OFFSETOF_MEMBER(Thread, tlsPtr_.top_reflective_handle_scope) ==
+ CHECKED(offset_tlsptr_end - OFFSETOF_MEMBER(Thread, tlsPtr_.method_trace_buffer_index) ==
sizeof(void*),
"async_exception last field");
}