Skip to content

gateway: compress frontend input payloads#6745

Draft
crazy-max wants to merge 1 commit into
moby:masterfrom
crazy-max:inputs-grpc-gzip
Draft

gateway: compress frontend input payloads#6745
crazy-max wants to merge 1 commit into
moby:masterfrom
crazy-max:inputs-grpc-gzip

Conversation

@crazy-max

Copy link
Copy Markdown
Member

fixes #6726

The gateway client now requests gzip compression for Inputs() calls and for Solve() calls that include FrontendInputs, and the gateway server registers grpc-go gzip support.

Comment thread frontend/dockerfile/dockerfile_test.go Outdated
Comment on lines +7356 to +7363
i.mu.Lock()
i.calls++
for _, opt := range opts {
if compressor, ok := opt.(grpc.CompressorCallOption); ok && compressor.CompressorType == grpcgzip.Name {
i.compressed = true
}
}
i.mu.Unlock()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think just using an atomic int is probably easier here.

}

resp, err := c.client.Inputs(ctx, &pb.InputsRequest{})
resp, err := c.client.Inputs(ctx, &pb.InputsRequest{}, grpc.UseCompressor(gzip.Name))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I assume that if the server doesn't have the capability to do the compression that this just falls back and operates correctly?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch. grpc-go does not negotiate this down if the server cannot decompress the request. It returns codes.Unimplemented before the handler runs with grpc: Decompressor is not installed for grpc-encoding "gzip" 🙈

Maybe we could have a fallback for that exact error so newer frontends retry Inputs and Solve without compression when talking to an older buildkitd that has not registered gzip? 🤔

That only preserves compatibility for payloads that already fit uncompressed. Large frontend input fan-in payloads can still hit the old max-message behavior against older daemons, which is expected.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@crazy-max crazy-max force-pushed the inputs-grpc-gzip branch from 0f29d7a to a8a7dbe Compare May 7, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

additional_contexts fan-in hits 4 MB gRPC limit at small N — duplicating tree serialization

2 participants