Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit ad0b0ed2 authored by Zimuzo Ezeozue's avatar Zimuzo Ezeozue
Browse files

Improve PerfettoTrace API

The old API was of the form:

PerfettoTrace.instant(category, name, extra).

This was not ideal for a few reasons:
1. Initializing the thread local extra was decoupled from the call
to emit an event and could be error prone if people initialize an
extra away from the point where it's emitted.

2. This call would ideally be wrapped around a check for isTraceEnabled
to avoid paying the cost of initializing the method parameters.

There was an alternative API that accepted a lambda, but that incurs
an object allocation on each call which is bad for the GC.

The new API is of the form:
PerfettoTrace.instant(category, name)
  .addArg(String val, Object... args)
  .emit().

This addresses both problems mentioned above. When tracing is disabled,
each intermediat call returns a NoOpBuilder that just returns 'this'.

Also fixed use-after-free with JNI string extraction.

Bug: 303199244
Flag: android.os.perfetto_sdk_tracing_v2
Test: atest PerfettoTraceTest

Change-Id: I6e732c58275d6ee00bc7c492a804ac32e5bcb47c
parent 7a78b07a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment