Introduce base::CircularQueue and improve trace processor sorter

This CL introduce a queue container backed by a circular array.
This vastly improves TraceSorter's performance, because it makes
delete-front O(1) (% invoking dtors), but still allows std::sort()
of the elements with the same cost of a vector.

This solution is also faster than using a std::deque for |events_|
instead of the std::vector, this is because CircularBuffer is way
simpler than a std::deque.

Benchmark of sorting-stage, obtained commenting out the parsing
stage and running on a 7GB trace [1] on a macbook pro 15 2018.

std::vector: 70 MB/s
std::deque: 260 MB/s
CircularBuffer: 285 MB/s

More CLs will further improve the sorter, but for now this CL alone
makes the trace processor cope better with large traces.

[1] SHA1: ad54e7de3a7,
    trace-walleye-QP1A.190211.001-2019-02-15-20-27-27.perfetto-trace
    from www/~primiano/perfetto/sample_traces

Test: perfetto_unittests --gtest_filter=CircularBufferTest.*
Change-Id: Ie804f54e08d7a9d374aefbe6141cbba65ddf25ec
7 files changed
tree: 1674d293ba03b07a7dad88291a4a52eeae8bdd58
  1. build_overrides/
  2. buildtools/
  3. debian/
  4. docs/
  5. gn/
  6. include/
  7. infra/
  8. protos/
  9. src/
  10. test/
  11. tools/
  12. ui/
  13. .clang-format
  14. .gitignore
  15. .gn
  16. .travis.yml
  17. Android.bp
  18. Android.bp.extras
  19. BUILD.gn
  20. codereview.settings
  21. heapprofd.rc
  22. MODULE_LICENSE_APACHE2
  23. NOTICE
  24. OWNERS
  25. perfetto.rc
  26. PRESUBMIT.py
  27. README.chromium
  28. README.md
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.