Skip to content

Commit 277eea1

Browse files
committed
add chunking function to RPCs
1 parent 0f9daf8 commit 277eea1

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

server/remote_cache/capabilities_server/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ go_library(
1111
"//proto:semver_go_proto",
1212
"//server/environment",
1313
"//server/real_environment",
14+
"//server/remote_cache/chunking",
1415
"//server/remote_cache/config",
1516
"//server/remote_cache/digest",
1617
"//server/util/bazel_request",

server/remote_cache/capabilities_server/capabilities_server.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/buildbuddy-io/buildbuddy/server/environment"
77
"github.com/buildbuddy-io/buildbuddy/server/real_environment"
8+
"github.com/buildbuddy-io/buildbuddy/server/remote_cache/chunking"
89
"github.com/buildbuddy-io/buildbuddy/server/remote_cache/digest"
910
"github.com/buildbuddy-io/buildbuddy/server/util/bazel_request"
1011

@@ -64,8 +65,10 @@ func (s *CapabilitiesServer) GetCapabilities(ctx context.Context, req *repb.GetC
6465
}
6566
if s.supportCAS {
6667
splitSpliceEnabled := false
68+
chunkingEnabled := false
6769
if efp := s.env.GetExperimentFlagProvider(); efp != nil {
6870
splitSpliceEnabled = efp.Boolean(ctx, "cache.split_splice_enabled", false)
71+
chunkingEnabled = chunking.Enabled(ctx, efp)
6972
}
7073

7174
c.CacheCapabilities = &repb.CacheCapabilities{
@@ -88,6 +91,13 @@ func (s *CapabilitiesServer) GetCapabilities(ctx context.Context, req *repb.GetC
8891
SplitBlobSupport: splitSpliceEnabled,
8992
SpliceBlobSupport: splitSpliceEnabled,
9093
}
94+
95+
if chunkingEnabled {
96+
c.CacheCapabilities.FastCdc_2020Params = &repb.FastCdc2020Params{
97+
AvgChunkSizeBytes: uint64(chunking.MaxChunkSizeBytes() / 4),
98+
Seed: 0,
99+
}
100+
}
91101
}
92102
if s.supportRemoteExec {
93103
c.ExecutionCapabilities = &repb.ExecutionCapabilities{

server/remote_cache/chunking/chunking.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ type Manifest struct {
176176

177177
func (cm *Manifest) ToSplitBlobResponse() *repb.SplitBlobResponse {
178178
return &repb.SplitBlobResponse{
179-
ChunkDigests: cm.ChunkDigests,
179+
ChunkDigests: cm.ChunkDigests,
180+
ChunkingFunction: repb.ChunkingFunction_FAST_CDC_2020,
180181
}
181182
}
182183

@@ -190,10 +191,11 @@ func (cm *Manifest) ToFindMissingBlobsRequest() *repb.FindMissingBlobsRequest {
190191

191192
func (cm *Manifest) ToSpliceBlobRequest() *repb.SpliceBlobRequest {
192193
return &repb.SpliceBlobRequest{
193-
BlobDigest: cm.BlobDigest,
194-
ChunkDigests: cm.ChunkDigests,
195-
InstanceName: cm.InstanceName,
196-
DigestFunction: cm.DigestFunction,
194+
BlobDigest: cm.BlobDigest,
195+
ChunkDigests: cm.ChunkDigests,
196+
InstanceName: cm.InstanceName,
197+
DigestFunction: cm.DigestFunction,
198+
ChunkingFunction: repb.ChunkingFunction_FAST_CDC_2020,
197199
}
198200
}
199201

server/remote_cache/content_addressable_storage_server/content_addressable_storage_server.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,10 @@ func (s *ContentAddressableStorageServer) SpliceBlob(ctx context.Context, req *r
11671167
return nil, status.UnimplementedErrorf("SpliceBlob RPC is not currently enabled")
11681168
}
11691169

1170+
if cf := req.GetChunkingFunction(); cf != repb.ChunkingFunction_FAST_CDC_2020 {
1171+
return nil, status.InvalidArgumentErrorf("unsupported chunking function %v, only FAST_CDC_2020 is supported", cf)
1172+
}
1173+
11701174
if req.GetBlobDigest() == nil {
11711175
return nil, status.UnimplementedError("SpliceBlob with no blob_digest is not supported")
11721176
}
@@ -1204,6 +1208,11 @@ func (s *ContentAddressableStorageServer) SplitBlob(ctx context.Context, req *re
12041208
return nil, status.UnimplementedErrorf("SplitBlob RPC is not currently enabled")
12051209
}
12061210

1211+
cf := req.GetChunkingFunction()
1212+
if cf != repb.ChunkingFunction_UNKNOWN && cf != repb.ChunkingFunction_FAST_CDC_2020 {
1213+
return nil, status.InvalidArgumentErrorf("unsupported chunking function %v", cf)
1214+
}
1215+
12071216
if req.GetBlobDigest() == nil {
12081217
return nil, status.InvalidArgumentError("blob_digest is required")
12091218
}

0 commit comments

Comments
 (0)