Remove unnecessary interface from Perfetto APIs

1. Removed the Builder interfaces from PerfettoTrackEventExtra
to improve performance. The interface was needed for a
NoOp impl when tracing was disabled. Instead, we just store
a boolean in the builder impl representing whether
the category is enabled or not, all the builder methods
return early if false. This saves an additional dependent load
instruction and an adrp + ldr sequence. This improves the
benchmark by a few nanos which adds up for each builder method
executed.

2. Moved the check* calls behind a DEBUG flag. This
elided the function calls entirely which were also getting inlined
and likely spilling the instruction cache. It's a debugging check
when generating protos. Besides, proto generation code is likely
to change in coming cls.

3. Added a setFlow/setTerminatingFlow call. This limits flows that
can be added to an event to at most 1 flow and terminating flow.
This is the most common case in practice anyways and we can avoid
the expensive indirection to get a flow via the Pool class.

godbolt playground to analyze the generated dex2oat code:
https://godbolt.org/z/Er9Gjvhfd

In a follow up, I'll remove addFlow/addTerminatingFlow

Test: atest PerfettoTest
Test: atest TracePerfTest
Bug: 303199244
Flag: android.os.perfetto_sdk_tracing_v2
Change-Id: I38f9853567734425ef8721dbbd93df8d83d7e257
diff --git a/boot/boot-image-profile-extra.txt b/boot/boot-image-profile-extra.txt
index ced0d17..ce99bfe 100644
--- a/boot/boot-image-profile-extra.txt
+++ b/boot/boot-image-profile-extra.txt
@@ -45,11 +45,15 @@
 HSPLandroid/os/MessageQueue$StackNodeType;->*
 HSPLandroid/os/MessageQueue$StateNode;->*
 HSPLandroid/os/MessageQueue$TimedParkStateNode;->*
+
+# For now, compile all methods in PerfettoTrace and PerfettoTrackEventExtra.
+# Similar to the existing Trace APIs, these new APIs can impact the performance
+# of many subsystems including MessageQueue. This also keeps benchmark
+# comparisons between both APIs fair.
 HSPLandroid/os/PerfettoTrace$Category;->*
 HSPLandroid/os/PerfettoTrace;->*
 HSPLandroid/os/PerfettoTrackEventExtra;->*
-HSPLandroid/os/PerfettoTrackEventExtra$BuilderImpl;->*
-HSPLandroid/os/PerfettoTrackEventExtra$NoOpBuilder;->*
+HSPLandroid/os/PerfettoTrackEventExtra$Builder;->*
 HSPLandroid/os/PerfettoTrackEventExtra$ArgBool;->*
 HSPLandroid/os/PerfettoTrackEventExtra$ArgInt64;->*
 HSPLandroid/os/PerfettoTrackEventExtra$ArgDouble;->*