Skip to content

perfetto: add Zstd as a trace compression codec#6459

Open
sashwinbalaji wants to merge 3 commits into
mainfrom
dev/sashwinbalaji/zstd_traced
Open

perfetto: add Zstd as a trace compression codec#6459
sashwinbalaji wants to merge 3 commits into
mainfrom
dev/sashwinbalaji/zstd_traced

Conversation

@sashwinbalaji

@sashwinbalaji sashwinbalaji commented Jul 1, 2026

Copy link
Copy Markdown
Member

The tracing service could already compress its output with deflate. This
adds Zstd, which produces smaller traces at a similar speed.

  • Traces opt in with the new TraceConfig.compression field: set
    compression.zstd for Zstd or compression.deflate for deflate. If both
    are set, the higher field number wins (so zstd over deflate).
  • Zstd's level is configurable via compression.zstd.level (1 fastest to 22
    smallest; 0 or unset uses zstd's default).
  • The old compression_type field is now deprecated but still honored, so
    services that predate compression keep compressing.
  • The service picks the codec from the config and runs it directly. A
    codec's library is only linked when its build flag (PERFETTO_ZLIB /
    PERFETTO_ZSTD) is on, so libz/libzstd stay out of builds that don't use
    compression, such as the SDK.
  • Each codec is configured by its own proto message, so the service never
    needs to know a codec's specific options.
  • Adding a codec later (e.g. lz4) is a new compressor file, one branch in
    the service, and a proto sub-message - nothing else changes.

@sashwinbalaji sashwinbalaji force-pushed the dev/sashwinbalaji/zstd_traced branch 3 times, most recently from d056538 to c4bdcce Compare July 2, 2026 11:28
@primiano primiano self-requested a review July 2, 2026 13:11
@sashwinbalaji sashwinbalaji force-pushed the dev/sashwinbalaji/zstd_traced branch from c4bdcce to e9328ad Compare July 2, 2026 15:55
@sashwinbalaji sashwinbalaji marked this pull request as ready for review July 2, 2026 15:57
@sashwinbalaji sashwinbalaji requested a review from a team as a code owner July 2, 2026 15:57
Comment thread bazel/deps.bzl
Comment thread protos/perfetto/config/perfetto_config.proto Outdated

@primiano primiano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work really!
LGTM with a few minor comments

Comment thread bazel/deps.bzl
Comment thread protos/perfetto/config/trace_config.proto
Comment thread src/tracing/service/zstd_compressor.cc Outdated
Comment thread src/tracing/service/zstd_compressor.cc Outdated
Comment thread src/tracing/service/zstd_compressor.h Outdated
@sashwinbalaji sashwinbalaji force-pushed the dev/sashwinbalaji/zstd_traced branch from e9328ad to 77ee6d1 Compare July 6, 2026 14:03
The tracing service could already compress its output with deflate. This
adds Zstd, which produces smaller traces at a similar speed.

- Traces opt in with the new TraceConfig.compression field: set
  compression.zstd for Zstd or compression.deflate for deflate. If both
  are set, the higher field number wins (so zstd over deflate).
- Zstd's level is configurable via compression.zstd.level (1 fastest to 22
  smallest; 0 or unset uses zstd's default).
- The old compression_type field is now deprecated but still honored, so
  services that predate `compression` keep compressing.
- The service picks the codec from the config and runs it directly. A
  codec's library is only linked when its build flag (PERFETTO_ZLIB /
  PERFETTO_ZSTD) is on, so libz/libzstd stay out of builds that don't use
  compression, such as the SDK.
- Each codec is configured by its own proto message, so the service never
  needs to know a codec's specific options.
- Adding a codec later (e.g. lz4) is a new compressor file, one branch in
  the service, and a proto sub-message - nothing else changes.
@sashwinbalaji sashwinbalaji force-pushed the dev/sashwinbalaji/zstd_traced branch from 77ee6d1 to 380a9be Compare July 6, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants