profile_module: omit packets referencing invalid callstack internings

This came up with an older (Android R) trace with a ring buffer holding
the perf_sample packets. The first N perf_sample packets were
referencing internings that were overwritten by the buffer wrapping. The
rest of the packets were fully well-formed since the tracing config
requested periodic incremental state clears, so the profiler stopped
referencing the old internings later in the packet sequence.

Newer traced_perf builds use SEQ_NEEDS_INCREMENTAL_STATE sequence flag,
which avoids this case as the pre-incremental-reset packets don't reach
the profile module parsing stage.

Distinguishing this case from counter-only profiles ended up being
a bit tricky since those still reference a valid-but-empty callstack
with zero frames. I chose to depend on the fact that the implementation
always ends up setting the empty callstack's interning id to "1", as
it is also the sentinel root node in the interning trie.

Alternatively, we could make the stack_profile_tracker identify the
zero-frame callstack's id dynamically, but that's not necessary at this
point.

Change-Id: I4cc4efc1284672c40f9fe194c9744cb7607de354
Bug: 218988616
2 files changed
tree: b4427ed12f6150a4c912b1ffd67acbfadf2752fa
  1. .github/
  2. bazel/
  3. build_overrides/
  4. buildtools/
  5. debian/
  6. docs/
  7. examples/
  8. gn/
  9. include/
  10. infra/
  11. protos/
  12. python/
  13. src/
  14. test/
  15. tools/
  16. ui/
  17. .clang-format
  18. .clang-tidy
  19. .gitattributes
  20. .gitignore
  21. .gn
  22. .style.yapf
  23. Android.bp
  24. Android.bp.extras
  25. BUILD
  26. BUILD.extras
  27. BUILD.gn
  28. CHANGELOG
  29. codereview.settings
  30. DIR_METADATA
  31. heapprofd.rc
  32. LICENSE
  33. meson.build
  34. METADATA
  35. MODULE_LICENSE_APACHE2
  36. OWNERS
  37. perfetto.rc
  38. PerfettoIntegrationTests.xml
  39. PRESUBMIT.py
  40. README.chromium
  41. README.md
  42. TEST_MAPPING
  43. traced_perf.rc
  44. WORKSPACE
README.md

Perfetto - System profiling, app tracing and trace analysis

Perfetto is a production-grade open-source stack for performance instrumentation and trace analysis. It offers services and libraries and for recording system-level and app-level traces, native + java heap profiling, a library for analyzing traces using SQL and a web-based UI to visualize and explore multi-GB traces.

See https://perfetto.dev/docs or the /docs/ directory for documentation.