Skip to content

re_grpc: request zstd-compressed BatchReadBlobs responses#1371

Open
9999years wants to merge 1 commit into
facebook:mainfrom
MercuryTechnologies:batch-read-blobs-zstd
Open

re_grpc: request zstd-compressed BatchReadBlobs responses#1371
9999years wants to merge 1 commit into
facebook:mainfrom
MercuryTechnologies:batch-read-blobs-zstd

Conversation

@9999years

Copy link
Copy Markdown
Contributor

There are many small BatchReadBlobs requests, and they're large enough that compression would help. When the server advertises zstd support in its capabilities, advertise zstd as an acceptable response compressor and decompress any zstd-compressed blobs the server returns.

NB: It would be nice if we could only compress blobs above a certain size, but we don't know the size when we make the request. We continue to advertise IDENTITY an acceptable response compressor, so we may need to patch our cache server to choose an appropriate size threshold above which to compress data (Bazel chooses 100 bytes, AIUI).

In a moderately sized build with ~81,000 BatchReadBlobs requests, this patch shows significant benefits:

  • Request latency dropped:
    • p100: 16,653ms to 3,468ms (4.8x speedup)
    • p90: 953ms to 593ms
    • p75: 529ms to 312ms
    • p50: 235ms to 161ms
    • p25: 110ms to 96ms
    • p0: 67ms to 68ms
  • Cumulative blob size over the network dropped from 5,807MiB to 1,626MiB (3.57x compression ratio)
  • Blob size distribution over the wire improved:
    • p100: 3.7M to 741.8K
    • p90: 188.4K to 58.0K
    • p75: 103.2K to 33.9K
    • p50: 12.9K to 3.7K
    • p25: 32B to 45B (regression)
    • p0: 15B to 2B (regression)

…22)

There are many small `BatchReadBlobs` requests, and they're large enough
that compression would help. When the server advertises zstd support in
its capabilities, advertise zstd as an acceptable response compressor and
decompress any zstd-compressed blobs the server returns.

NB: It would be nice if we could only compress blobs above a certain
size, but we don't know the size when we make the request. We continue to
advertise IDENTITY an acceptable response compressor, so we may need to
patch our cache server to choose an appropriate size threshold above
which to compress data (Bazel chooses 100 bytes, AIUI).

In a moderately sized build with ~81,000 BatchReadBlobs requests, this
patch shows significant benefits:
- Request latency dropped:
  - p100: 16,653ms to 3,468ms (4.8x speedup)
  - p90: 953ms to 593ms
  - p75: 529ms to 312ms
  - p50: 235ms to 161ms
  - p25: 110ms to 96ms
  - p0: 67ms to 68ms
- Cumulative blob size over the network dropped from 5,807MiB to
  1,626MiB (3.57x compression ratio)
- Blob size distribution over the wire improved:
  - p100: 3.7M to 741.8K
  - p90: 188.4K to 58.0K
  - p75: 103.2K to 33.9K
  - p50: 12.9K to 3.7K
  - p25: 32B to 45B (regression)
  - p0: 15B to 2B (regression)
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 13, 2026
/// Maximum number of digests per `FindMissingBlobs` RPC.
find_missing_blobs_batch_size: usize,
/// Whether to request zstd-compressed `BatchReadBlobs` responses (server supports zstd).
batch_read_zstd: bool,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could have a set of supported compressors here instead, but we'd have to do a slightly more invasive refactoring. Let me know if you'd like me to do that.

@meta-codesync

meta-codesync Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D111767018. (Because this pull request was imported automatically, there will not be any future comments.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant