-
Notifications
You must be signed in to change notification settings - Fork 114
feat(grpcclients): add ZSTD compression support for gRPC CAS client #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
ca110e3 to
dac7b8e
Compare
|
I'd say, don't make this a separate storage backend. Just make it so that the existing CAS client caches the supported compressors returned by the last call to GetCapabilities() and uses that to determine whether to send requests that use Zstandard. |
dac7b8e to
715bd47
Compare
I think the client needs to be able to make the decision on whether to send the request compressed or not, similar to how Bazel does. We also probably want to define a compression threshold similar to Bazel, so clients can optimize based on their network properties. Maybe it'd be better to have the compression configuration separated a little bit. I updated the PR. |
07f7acf to
c153bc5
Compare
c153bc5 to
2596337
Compare
|
Friendly bump, @EdSchouten if you have time to take another look |
| // ByteStream.Read and ByteStream.Write. The server must support | ||
| // Zstd compression. If it is a bb_storage Instance, add 'ZSTD' to | ||
| // the list of supported compressors. | ||
| CompressedClientConfiguration compressed = 29; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of how this is named. Compression shouldn't be treated as a different kind of backend. It's merely a behavioral aspect of the gRPC CAS client. Right now the problem is that we don't have a dedicated message for that. For all storage backends (AC, CAS, ...) we only provide a buildbarn.configuration.grpc.ClientConfiguration. My recommendation would be to do one of the following things instead:
- Don't make any changes to the configuration schema, and simply respect what the server announces via
GetCapabilities(). - Add a
GrpcBlobAccessConfigurationand change the type of fieldgrpcto that. This means that options pertaining to compression and such will be available for all backends, but they will be no-ops for !CAS. Though slightly confusing, it does have the advantage that setups that merely want to forward all CAS/AC/... traffic can continue to write something like this:
{
local backend = ...,
contentAddressableStorage: backend,
actionCache: backend,
initialSizeClassCache: backend,
...
}- Rename
CompressedClientConfigurationtoGrpcContentAddressableStorageBlobAccessConfigurationand thiscompressedfield togrpc_content_addressable_storage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added GrpcBlobAccessConfiguration with enable_zstd_compression field that's a no-op for non-CAS backends.
|
Hey @tyler-french - do you have time to pick this back up? |
|
Does this close #158? |
73a5397 to
08f47ce
Compare
08f47ce to
6e0879f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds ZSTD compression support to the gRPC CAS (Content Addressable Storage) client to optimize network transfer of large blobs. The implementation introduces a new GrpcBlobAccessConfiguration protobuf message that wraps the existing gRPC client configuration with an optional compression flag.
Key changes:
- New
GrpcBlobAccessConfigurationprotobuf message withenable_zstd_compressionboolean flag - Compression negotiation via
GetCapabilities()to check server support for ZSTD - Compression/decompression readers and writers for ByteStream operations with a hardcoded 100-byte threshold
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 17 comments.
Show a summary per file
| File | Description |
|---|---|
pkg/proto/configuration/blobstore/blobstore.proto |
Defines new GrpcBlobAccessConfiguration message with compression flag |
pkg/proto/configuration/blobstore/blobstore.pb.go |
Generated protobuf Go code for the new configuration message |
pkg/blobstore/grpcclients/cas_blob_access.go |
Implements ZSTD compression/decompression for ByteStream Read/Write operations |
pkg/blobstore/grpcclients/cas_blob_access_test.go |
Adds test coverage for compressed and uncompressed blob operations |
pkg/blobstore/grpcclients/BUILD.bazel |
Adds zstd library dependency |
pkg/blobstore/configuration/cas_blob_access_creator.go |
Configures CAS client with 100-byte compression threshold when enabled |
pkg/blobstore/configuration/ac_blob_access_creator.go |
Updates to extract client from new wrapper configuration |
pkg/blobstore/configuration/icas_blob_access_creator.go |
Updates to extract client from new wrapper configuration |
pkg/blobstore/configuration/iscc_blob_access_creator.go |
Updates to extract client from new wrapper configuration |
pkg/blobstore/configuration/fsac_blob_access_creator.go |
Updates to extract client from new wrapper configuration |
Comments suppressed due to low confidence (1)
pkg/blobstore/grpcclients/cas_blob_access.go:402
- The SupportedCompressors field is stored internally but is not included in the returned ServerCapabilities. This means callers of GetCapabilities won't see the compression support information, which could be needed for debugging or client decision-making. Consider adding SupportedCompressors to the returned CacheCapabilities structure.
return &remoteexecution.ServerCapabilities{
CacheCapabilities: &remoteexecution.CacheCapabilities{
DigestFunctions: digest.RemoveUnsupportedDigestFunctions(cacheCapabilities.DigestFunctions),
},
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7efe3d7 to
631b6b7
Compare
631b6b7 to
1c604dc
Compare

This PR adds a new compression control to the grpc client configuration that wraps the existing gRPC client with ZSTD compression support for ByteStream operations.
This is a pre-requisite to supporting compressed bb-clientd.
Example Configuration
Frontend:
{ blobstore: { contentAddressableStorage: { sharding: { shards: { "0": { backend: { grpc: { client: { address: 'storage-0:8981' }, enableZstdCompression: true, } }, weight: 1, }, "1": { backend: { grpc: { client: { address: 'storage-1:8981' }, enableZstdCompression: true, } }, weight: 1, }, }, }, }, }, }Storage backend:
{ supportedCompressors: ['ZSTD'], }