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
@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

@tonistiigi tonistiigi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this works like this. Both of these caps requests are checking the version of the daemon but in reality, it is the client talking with the frontend here, and both of the need to agree. Daemon supporting this feature and client setting it, doesn't mean that frontend know how to read it out.

Additionally this is only a stopgap that gives a little bit more room, similar of what we would get by just increasing the limits.

If we do add new frontend cap, then the cap can be something that says that inputs have been deduplicated, meaning the matching parts of the LLB branches have been removed and on load they can be looked up from other inputs.

Client can then do something like this:

  • check if there are multiple inputs and if deduplicating would win significant space (to not error for missing cap for no reason)
  • deduplicate and make request with the cap
  • if frontend doesn't support cap then it will return typed error
  • client can retry with old duplicated format and hope to not hit limits.

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

3 participants