Repository navigation
Remote cache: the gRPC interface of the Remote Execution API (#19) - #79
Open
ambroise-leclerc wants to merge 4 commits into
Open
ambroise-leclerc wants to merge 4 commits into
ambroise-leclerc wants to merge 4 commits into
Conversation
ambroise-leclerc
force-pushed
the
19-grpc
branch
from
December 1, 2026 01:00
402aafe to
d83ccc6
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The change still has unresolved moderate issues affecting performance (per-frame heap allocations), protocol correctness (invalid HTTP/2 WINDOW_UPDATE handling), and functional interoperability (gRPC has() sending size_bytes = 0), indicating it isn’t ready for approval.
3 open issues
What changed in this PR
Adds support for Remote Execution API remote caches via the gRPC interface (grpc:// / grpcs://) by implementing an in-repo gRPC-over-HTTP/2 client and HPACK, wiring it into remote cache operations, and extending tests/docs.
Changes:
- Add
grpc://andgrpcs://URL support (including instance path) and route remote cache operations through REv2 gRPC services. - Introduce minimal HTTP/2 + HPACK + gRPC plumbing in-tree (
Grpc.cppm,Hpack.cppm) to avoid external gRPC/protobuf dependencies. - Expand unit/integration coverage and CI to exercise gRPC paths (framing, HPACK examples/malformed blocks, URL parsing, and ByteStream for larger blobs).
| File | Description |
|---|---|
| tests/spec/HttpSpec.cpp | Updates HTTP-related spec expectations to account for grpc:// and grpcs:// schemes in URL parsing/diagnostics. |
| tests/spec/HpackSpec.cpp | Adds HPACK unit tests covering RFC 7541 Appendix C examples and malformed header-block scenarios. |
| tests/spec/GrpcSpec.cpp | Introduces gRPC-focused unit tests for message framing and grpc(s):// URL parsing behavior. |
| tests/integration/Remote.cmake | Extends remote integration testing to exercise gRPC mode, including a large-blob round trip through ByteStream. |
| tests/CMakeLists.txt | Registers the new gRPC and HPACK spec tests in the test build configuration. |
| src/cppmcache/RemoteTransportDisabled.cpp | Updates the disabled transport stub to match the transport API changes (including the ALPN parameter). |
| src/cppmcache/RemoteTransport.hpp | Extends the remote transport interface to accept an ALPN protocol name when opening connections. |
| src/cppmcache/RemoteTransport.cpp | Implements/plumbs ALPN selection for TLS connections through the updated transport open API. |
| src/cppmcache/Remote.cppm | Adds the gRPC-backed remote cache execution path implementing REv2 ActionCache/CAS/ByteStream calls with batching and call reuse. |
| src/cppmcache/Http.cppm | Extends URL parsing/printing and related diagnostics to recognize grpc:// and grpcs:// remote cache URLs. |
| src/cppmcache/Hpack.cppm | Implements HPACK encoding (literal fields) and full decoding (dynamic table, size updates, and Huffman) needed for HTTP/2 headers. |
| src/cppmcache/Grpc.cppm | Implements a minimal gRPC client over HTTP/2 tailored for remote cache calls, including framing, settings, and flow control handling. |
| src/cppmcache/Cache.cppm | Adjusts cache logic to propagate digest sizing requirements needed by the gRPC/REv2 code path (including manifest key handling). |
| README.md | Documents how to use grpc(s):// remote cache URLs and the high-level behavior of gRPC mode. |
| docs/usage.md | Adds user-facing guidance for configuring and using the remote cache over gRPC, including notable behavior and limits. |
| CMakeLists.txt | Wires the new module sources (HPACK/gRPC) into the build configuration. |
| .github/workflows/ci.yml | Updates CI to run integration coverage against bazel-remote’s gRPC endpoints (plain and TLS) alongside existing checks. |
Review effort: Balanced
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
ambroise-leclerc
force-pushed
the
19-grpc
branch
3 times, most recently
from
December 1, 2026 02:22
892eb8b to
1fcc1a5
Compare
- grpc:// and grpcs:// URLs, the path being the instance name. grpcs is TLS with ALPN h2 and the same authentication and credentials as https. - An HTTP/2 client written here (Grpc.cppm): prior knowledge or ALPN, the largest windows advertised, the server's windows and frame size honoured, no push, GOAWAY and RST_STREAM ending the call. HPACK (Hpack.cppm): literal fields when encoding, the whole format with Huffman coding when decoding. - The operations of the remote cache become ActionCache.GetActionResult and UpdateActionResult, FindMissingBlobs, BatchReadBlobs and BatchUpdateBlobs below 3 MiB, ByteStream.Read and Write above. A manifest key gets a nominal digest size of 1: servers refuse 0 for a hash other than the empty blob's. - Tests: the examples of RFC 7541, Appendix C; gRPC framing and URLs; a 5 MB output in the remote integration test; CI runs that test against bazel-remote's gRPC port, plain and with TLS and Basic authentication.
- A call on a connection kept from an earlier one is made again once on a new connection when it fails: the server may have closed an idle connection. - The receive windows start at their largest and are widened again once half of either is used, so that a long connection or a large download does not stall.
A server whose limit on the size of a batch is below 3 MiB answers INVALID_ARGUMENT or RESOURCE_EXHAUSTED: the blobs of that batch then go one by one through ByteStream, which has no such limit, instead of failing.
… a size (#19) - The 64 KiB buffer of readFrame() is allocated once per channel. - A WINDOW_UPDATE of zero, or one that takes a window beyond 2^31 - 1, ends the connection as a protocol error (RFC 9113, section 6.9). - RemoteCache::has() takes the size of the digest, which gRPC needs.
ambroise-leclerc
force-pushed
the
19-grpc
branch
from
December 1, 2026 03:15
1fcc1a5 to
153b97a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
cppmcache can now use servers that offer only the gRPC interface of the Remote Execution API, such as BuildBuddy and Buildbarn. Last part of epic #38, stacked on #78.
grpc://host[:port][/instance]andgrpcs://…. The path is the instance name.grpcsis TLS with ALPNh2, with the same Web PKI authentication and credentials ashttps(Remote cache: TLS and authentication #17); the credentials go in theauthorizationmetadata.Proto.cppm). The libraries would have added a very heavy dependency next toimport std;, and every project importing cppmcache with CPM would have had to build it.Grpc.cppm: an HTTP/2 client limited to what cache calls need: one connection, one call at a time, prior knowledge or ALPN. It advertises the largest windows, honours the server's windows and frame size, refuses push, and ends a call on GOAWAY or RST_STREAM.Hpack.cppm: HPACK. The encoder writes literal fields only, withauthorizationmarked never-indexed. The decoder covers the whole format: dynamic table, size updates, Huffman. The Huffman and static tables are generated from the text of RFC 7541 and checked there: 257 codes, each matching its bit pattern, forming a complete prefix code.ActionCache.GetActionResultandUpdateActionResult;FindMissingBlobs;BatchReadBlobsandBatchUpdateBlobsfor blobs up to 3 MiB per batch;ByteStream.ReadandWriteabove that, in chunks of 1 MiB. Consecutive operations of one kind share a call.Invalid zero-length SHA256 hash).compressed-blobs/zstdresources would be the next step.Closes #19
Verification
ctest: 109/109 passedctest: 109/109 passed; clang-tidy clean on the files touchedclang-format --dry-run -Werroron the files touchedtools/check_attribution.pytests/integration/Remote.cmakewithCPPMCACHE_REMOTE=grpc://…:9092: passed, including a new step with a 5 MB output that goes through ByteStream both ways;grpcs://, the test root, Basic authentication (htpasswd), an untrusted root, wrong credentials (gRPC status 16) and a password read from a file: passed;Two defects found that way and fixed before this PR:
FindMissingBlobsResponse.missing_blob_digestsis field 2, not 1 (no blob was uploaded, so bazel-remote, which checks an ActionResult's dependencies, answered NOT FOUND); and the size-0 digest above.Not verified: servers other than bazel-remote (BuildBuddy, Buildbarn); Windows and macOS (CI does not run bazel-remote there); a server that sends a header block in several CONTINUATION frames.
Effect on cache keys
None.