traced_perf: rework reading granularity, add unwind queue

The implementation is kept single-threaded, but the organization roughly
follows the intended unwinder-on-a-dedicated-thread approach.

There's a mix of smaller changes, summarizing in no particular order:
* Reading now consumes individual records instead of chunks of the ring buffer.
  (The records will be either a sample, or a PERF_RECORD_LOST if the kernel has
  lost samples due to ring buffer capacity). I didn't want to bubble up the
  record type decision all the way to the PerfProducer, proposing the
  callback+return format of ReadUntilSample to abstract most of it away (though
  noting that it ends up hiding a nested loop).
* Reading parses the event directly out of the ring buffer (copying the
  populated stack bytes onto the heap, etc).
* The wrapped ringbuffer case is handled by reconstructing (with a pair of
  memcpy's) the event in a dedicated buffer, and returning a pointer to that.
* Added boot clock timestamps to samples.
* Added proc-fd interface, and direct/signal-based implementations.
* Added per-datasource unwinder queues (for now simply std::deque while we're
  single-threaded, imagine a ring buffer in the future).

On unwinding queues specifically - the slots are filled in order (from the
perspective of a given per-cpu buffer reader). The parsing however can be out
of order, as samples are kept in the queue until their proc-fds are ready (or
assumed to not be obtainable for the remainder of the data source's lifetime).
The "unwind" tick keep walking the queue in order, only releasing the completed
entries once they reach the "oldest" end of the queue.

Bug: 144281346
Change-Id: Ic59c153c1c80e04b5e5bfb25656c10bc5e80dd11
12 files changed
tree: 3b0ebfaba9f99755d47b809b905e789041d7e178
  1. bazel/
  2. build_overrides/
  3. buildtools/
  4. debian/
  5. docs/
  6. gn/
  7. include/
  8. infra/
  9. protos/
  10. src/
  11. test/
  12. tools/
  13. ui/
  14. .clang-format
  15. .gitignore
  16. .gn
  17. .style.yapf
  18. Android.bp
  19. Android.bp.extras
  20. BUILD
  21. BUILD.extras
  22. BUILD.gn
  23. codereview.settings
  24. heapprofd.rc
  25. LICENSE
  26. MODULE_LICENSE_APACHE2
  27. NOTICE
  28. OWNERS
  29. perfetto.rc
  30. PRESUBMIT.py
  31. README.chromium
  32. README.md
  33. TEST_MAPPING
  34. WORKSPACE
README.md

Perfetto - Performance instrumentation and tracing

Perfetto is an open-source project for performance instrumentation and tracing of Linux/Android/Chrome platforms and user-space apps.

See www.perfetto.dev for docs.

Contributing

See /docs/contributing.md for instructions.

The source-of-truth repo is Android's Gerrit. The GitHub repo is a read-only mirror.

Bugs

  • For bugs affecting Android or the tracing internals use the internal bug tracker (go/perfetto-bugs).
  • For bugs affecting Chrome use http://crbug.com, Component:Speed>Tracing label:Perfetto.

Community

You can reach us on our Discord channel. If you prefer using IRC we have an experimental Discord <> IRC bridge synced with #perfetto-dev on Freenode.