Skip to content

gateway: compress frontend input payloads#6745

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

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

Conversation

@crazy-max

@crazy-max crazy-max commented May 6, 2026

Copy link
Copy Markdown
Member

fixes #6726

The gateway server now registers gzip decompression support and advertises a gateway gzip capability. The gateway client uses gzip for Inputs calls and for Solve calls with FrontendInputs only when that capability is present.

Large frontend input fan-in can duplicate LLB definition bytes enough to hit gRPC message limits. Gzip reduces that wire size while the capability gate keeps newer clients compatible with older daemons.

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.

Comment thread frontend/gateway/grpcclient/client.go Outdated
}

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.

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.

Added a gateway gzip capability

@crazy-max crazy-max force-pushed the inputs-grpc-gzip branch from 0f29d7a to a8a7dbe Compare May 7, 2026 16:48
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@crazy-max crazy-max added this to the v0.32.0 milestone Jul 1, 2026
@crazy-max crazy-max requested a review from tonistiigi July 1, 2026 10:52
@crazy-max crazy-max marked this pull request as ready for review July 1, 2026 10:53
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