trace_processor: fix support for optional<stringid> columns

We didn't have proper support for optional<stringid> columns because
we expected all stringid columns to directly use stringid as stringpool
has a special id (0) reserved for null strings.

However, this is confusing for end users as it's not obvious why they
can't use it in the macro tables. Moreover, the current code silently
failed without any warnings and only crashed in debug.

We don't want to have nullability at the sparsevector level because it
would require an additional layer of null checking in all the string
filtering code

Therefore, there are two options for fixing this:
1. We redirect base::nullopt -> null string id at insert time. This
   allows the rest of the code to work as is and doesn't add an extra
   overhead at query time.
2. We add a static_assert to ban optional<stringid> and educate
   users to use stringid instead. This makes the internal structure
   of macro tables clearer than option 1 but is surprising and forces
   users to obscure intent of their column types.

This CL implements option 1 with the note that, one day, we may be able
to get rid of the nullability at the stringpool level; in this case, we
can remove this hack and treat strings just the same as we treat
integers.

Bug: 1142720466
Change-Id: Ied75ddfa6ba9ada16727612b60bcd7bba68dd011
3 files changed
tree: c3c9791ee17288c6efd03f81b9b08205d62c031a
  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. MODULE_LICENSE_APACHE2
  26. NOTICE
  27. OWNERS
  28. perfetto.rc
  29. PRESUBMIT.py
  30. README.chromium
  31. README.md
  32. TEST_MAPPING
  33. 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.

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.