Support gzip files in trace_to_text

Core change in trace_to_text:

1. Add `OnlineTraceToText` utility by refactoring the core TraceToText
   code to make it easy to use, easy to test independently without much
   boilerplate code and easy to compose with other streaming algorithms.
   Client OnlineTraceToText can continue to `feed` it a sequence of
   mem-blocks, and it will continue to write the output in a out_stream.

2. Rewrite trace_to_text driver function, which first figures out if the
   input file is gzip or proto files and setup/wire the streaming
   components as follows:

   when gzip file:

     {InputFile} --> {Streaming GzipDecompress} --> {OnlineTraceToText}
                                                      ||
                                                      ||
                                                      \/
                                                   {Output}

   when proto file:

     {InputFile} --> {OnlineTraceToText} --> {Output}

   The data is streamed from one component to the next one, in a
   sequence of mem-block, and finally written to the output_file/stdout.

3. Some other minor cleanup/refactoring in trace_to_text code.

4. Manual testing:

   For `example_android_trace_15s.gz` attached on b/148130323:

   >> ./tools/traceconv text /tmp/e_trace_15s           >   /tmp/p1.txt
   >> ./out/default/trace_to_text text /tmp/e_trace_15s  >  /tmp/p2.txt
   >> ./out/default/trace_to_text text /tmp/e_trace_15s.gz > /tmp/p3.txt
   >> md5sum /tmp/p1.txt
    ac7b8b397d3e5e543e91d2c909c35416  // [Baseline (before this CL)]
   >> md5sum /tmp/p2.txt
    ac7b8b397d3e5e543e91d2c909c35416  // [trace2text after this CL]
   >> md5sum /tmp/p3.txt
    ac7b8b397d3e5e543e91d2c909c35416  // [decompress + trace2text after
                                          this CL]

Bug: 148130323
Change-Id: I2c8aa080aba45434e202bd9ff99c4a20de69571e
14 files changed
tree: eb872299b160df8e20303888d50c8a526e20df29
  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.