diff options
author | 2025-02-23 11:41:24 +0000 | |
---|---|---|
committer | 2025-02-23 11:41:24 +0000 | |
commit | 0d4dced822b6ffc1aea46ea387e1cd312fc992d2 (patch) | |
tree | b7b0c15d9d9766f6c918f99a0193ee45b58178a1 | |
parent | 139fadb007cacfbdd554509c2a167bfaeae3a7cd (diff) |
Remove addFlow/TerminatingFlow
setFlow and setTerminatingFlow had been added in previous cl
to replace the addFlow methods. In practice, addFlow is very
unlikely to be used to add more than one edge to an event. In
these cases, there's a noticeable performance improvement when
using setFlow which avoids the call through to Pool of Flows.
Also fixed setFlow to accept long instead of int. The underlying
structs in the C SDK support uint64_t and this was just an
oversight.
Test: atest PerfettoTraceTest
Bug: 303199244
Flag: android.os.perfetto_sdk_tracing_v2
Change-Id: I3fdcbbd09921e865052bdca359a5ffb0cfe18900
-rw-r--r-- | apct-tests/perftests/core/src/android/os/TracePerfTest.java | 4 | ||||
-rw-r--r-- | core/java/android/os/CombinedMessageQueue/MessageQueue.java | 2 | ||||
-rw-r--r-- | core/java/android/os/Looper.java | 2 | ||||
-rw-r--r-- | core/java/android/os/Message.java | 4 | ||||
-rw-r--r-- | core/java/android/os/PerfettoTrackEventExtra.java | 40 |
5 files changed, 8 insertions, 44 deletions
diff --git a/apct-tests/perftests/core/src/android/os/TracePerfTest.java b/apct-tests/perftests/core/src/android/os/TracePerfTest.java index d9051240d399..00e1c1fdbf4b 100644 --- a/apct-tests/perftests/core/src/android/os/TracePerfTest.java +++ b/apct-tests/perftests/core/src/android/os/TracePerfTest.java @@ -147,7 +147,7 @@ public class TracePerfTest { .addField(1 /* sending_thread_name */, "foo") .endNested() .endProto() - .addTerminatingFlow(5) + .setTerminatingFlow(5) .emit(); BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); @@ -158,7 +158,7 @@ public class TracePerfTest { .addField(1 /* sending_thread_name */, "foo") .endNested() .endProto() - .addTerminatingFlow(5) + .setTerminatingFlow(5) .emit(); } } diff --git a/core/java/android/os/CombinedMessageQueue/MessageQueue.java b/core/java/android/os/CombinedMessageQueue/MessageQueue.java index 3c03bb5626c8..a39a19f682bc 100644 --- a/core/java/android/os/CombinedMessageQueue/MessageQueue.java +++ b/core/java/android/os/CombinedMessageQueue/MessageQueue.java @@ -232,7 +232,7 @@ public final class MessageQueue { traceMessageCount(); PerfettoTrace.instant(PerfettoTrace.MQ_CATEGORY, "message_queue_send") - .addFlow(msg.mEventId.get()) + .setFlow(msg.mEventId.get()) .beginProto() .beginNested(2004 /* message_queue */) .addField(2 /* receiving_thread_name */, mThread.getName()) diff --git a/core/java/android/os/Looper.java b/core/java/android/os/Looper.java index 1329b90538bb..3ff6e052335e 100644 --- a/core/java/android/os/Looper.java +++ b/core/java/android/os/Looper.java @@ -205,7 +205,7 @@ public final class Looper { .addField(1 /* sending_thread_name */, msg.mSendingThreadName) .endNested() .endProto() - .addTerminatingFlow(msg.mEventId.get()) + .setTerminatingFlow(msg.mEventId.get()) .emit(); // This must be in a local variabe, in case a UI event sets the logger diff --git a/core/java/android/os/Message.java b/core/java/android/os/Message.java index b22d1774d967..69e84e3b097a 100644 --- a/core/java/android/os/Message.java +++ b/core/java/android/os/Message.java @@ -23,7 +23,7 @@ import android.util.proto.ProtoOutputStream; import com.android.internal.annotations.VisibleForTesting; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; /** * @@ -43,7 +43,7 @@ public final class Message implements Parcelable { * * @hide Only for use within the system server. */ - public final AtomicInteger mEventId = new AtomicInteger(); + public final AtomicLong mEventId = new AtomicLong(); /** * User-defined message code so that the recipient can identify diff --git a/core/java/android/os/PerfettoTrackEventExtra.java b/core/java/android/os/PerfettoTrackEventExtra.java index f4b5dfe76f88..2848bcb8ad34 100644 --- a/core/java/android/os/PerfettoTrackEventExtra.java +++ b/core/java/android/os/PerfettoTrackEventExtra.java @@ -172,7 +172,6 @@ public final class PerfettoTrackEventExtra { private final Pool<FieldDouble> mFieldDoubleCache; private final Pool<FieldString> mFieldStringCache; private final Pool<FieldNested> mFieldNestedCache; - private final Pool<Flow> mFlowCache; private final Pool<Builder> mBuilderCache; private Builder() { @@ -187,7 +186,6 @@ public final class PerfettoTrackEventExtra { mFieldDoubleCache = mExtra.mFieldDoubleCache; mFieldStringCache = mExtra.mFieldStringCache; mFieldNestedCache = mExtra.mFieldNestedCache; - mFlowCache = mExtra.mFlowCache; mBuilderCache = mExtra.mBuilderCache; mCounterInt64 = mExtra.getCounterInt64(); @@ -227,7 +225,6 @@ public final class PerfettoTrackEventExtra { mFieldStringCache.reset(); mFieldNestedCache.reset(); mBuilderCache.reset(); - mFlowCache.reset(); mExtra.reset(); // Reset after on init in case the thread created builders without calling emit @@ -325,39 +322,7 @@ public final class PerfettoTrackEventExtra { /** * Adds a flow with {@code id}. */ - public Builder addFlow(int id) { - if (!mIsCategoryEnabled) { - return this; - } - if (DEBUG) { - checkParent(); - } - Flow flow = mFlowCache.get(sFlowSupplier); - flow.setProcessFlow(id); - mExtra.addPerfettoPointer(flow); - return this; - } - - /** - * Adds a terminating flow with {@code id}. - */ - public Builder addTerminatingFlow(int id) { - if (!mIsCategoryEnabled) { - return this; - } - if (DEBUG) { - checkParent(); - } - Flow flow = mFlowCache.get(sFlowSupplier); - flow.setProcessTerminatingFlow(id); - mExtra.addPerfettoPointer(flow); - return this; - } - - /** - * Adds a flow with {@code id}. - */ - public Builder setFlow(int id) { + public Builder setFlow(long id) { if (!mIsCategoryEnabled) { return this; } @@ -372,7 +337,7 @@ public final class PerfettoTrackEventExtra { /** * Adds a terminating flow with {@code id}. */ - public Builder setTerminatingFlow(int id) { + public Builder setTerminatingFlow(long id) { if (!mIsCategoryEnabled) { return this; } @@ -670,7 +635,6 @@ public final class PerfettoTrackEventExtra { private final Pool<FieldDouble> mFieldDoubleCache = new Pool(DEFAULT_EXTRA_CACHE_SIZE); private final Pool<FieldString> mFieldStringCache = new Pool(DEFAULT_EXTRA_CACHE_SIZE); private final Pool<FieldNested> mFieldNestedCache = new Pool(DEFAULT_EXTRA_CACHE_SIZE); - private final Pool<Flow> mFlowCache = new Pool(DEFAULT_EXTRA_CACHE_SIZE); private final Pool<Builder> mBuilderCache = new Pool(DEFAULT_EXTRA_CACHE_SIZE); private static final NativeAllocationRegistry sRegistry = |