perfetto: Prune empty TBv2 sequences without counting them
TBv2 now works out which empty sequences to delete when a GC runs, so
it no longer keeps a count of them.
We want to move sequence state out of TBv2 into its own class. The
count can't live in one sequence, so it would need a home outside that
class, and every chunk added or removed would have to keep it updated.
That ties each sequence to whatever holds the count. The count was only
best effort anyway, and each GC already had to check it again.
This changes two behaviours.
- When a GC runs: a write starts one once the sequence map has grown
enough since the last GC. Before, it started one once enough
sequences were empty.
- A GC can now delete with more than 1024 empty sequences, where
main needed more than 1152.
- If a read drains 2000 active writers, main trims to 1024 on the
next write. This keeps them all until the map grows, so gap
detection and rejection of consumed recommits survive.
- Which sequences go first: a GC deletes the least recently used empty
sequences. Before, it deleted the ones that became empty first. The
two differ only when an empty sequence is looked up again, by
RecordChunkV2DataLoss(), TryPatchChunkContents() or a rejected write.
The cost is that when many writers stop, their empty sequences stay in
memory until enough new writers arrive.
Perfetto is an open-source suite of tools for recording, visualizing and analyzing traces: timelines of what software and the system under it were doing. It is the default tracing system for Android and Chromium. System-wide recording works on Android and Linux. The tracing SDK, the UI and Trace Processor also run on macOS and Windows.
perf, Firefox Profiler, macOS Instruments, pprof, systrace, Fuchsia and more.Open an example Android trace without installing anything, or drag your own trace file onto ui.perfetto.dev.
On Android, with a device connected over adb:
curl -O https://raw.githubusercontent.com/google/perfetto/main/tools/record_android_trace python3 record_android_trace -o trace.pftrace -t 10s sched freq gfx view am wm
The trace opens in the Perfetto UI when recording finishes.
On Linux, record scheduling activity with tracebox:
curl -LO https://get.perfetto.dev/tracebox && chmod +x tracebox curl -LO https://raw.githubusercontent.com/google/perfetto/main/test/configs/scheduling.cfg sudo ./tracebox -o trace.pftrace --txt -c scheduling.cfg
For Chrome, use the recording page in the UI. To trace your own app, see in-app tracing.
curl -LO https://get.perfetto.dev/trace_processor && chmod +x trace_processor ./trace_processor query trace.pftrace \ "SELECT name, COUNT(*) AS cnt FROM slice GROUP BY name ORDER BY cnt DESC LIMIT 10"
Or from Python:
pip install perfetto
from perfetto.trace_processor import TraceProcessor tp = TraceProcessor(trace='trace.pftrace') print(tp.query('SELECT ts, dur, name FROM slice LIMIT 10').as_pandas_dataframe())
ftrace. (Linux cookbook)chrome://tracing, for debugging the browser, V8 and Blink. (Chrome tracing)Not sure where to start? How do I start using Perfetto? picks a path based on what you want to do.
Perfetto is a collection of components that work together:
traced, traced_probes) collect data from many processes and the kernel into a single trace file.See the documentation for the full picture.
See Community and getting help for more. We follow Google's Open Source Community Guidelines.
Contributions are welcome. The contributor guide covers building, testing and sending pull requests.
The Debian packaging of Perfetto is maintained in the Debian Perfetto Salsa repository.
Apache 2.0. See LICENSE for details.