Add bazel flag for max_cas_entry size.
Description of the feature request:
As of today, the max_cas_entry_size is declared at the server side. In the event that Bazel sends a write request containing a digest larger than the specified max_cas_entry_size, the remote cache throws an 'out_of_range' error. By introducing a Bazel flag for max_cas_entry_size, it becomes possible to validate it on the client side, potentially eliminating the need for a round trip to the server. This improvement has the potential to enhance build performance.
What underlying problem are you trying to solve with this feature?
Improved build performance with remote cache.
@tjgq @sgowroji @Pavank1992 could you give an estimate of how much work this is? I'd be willing to help, but need to know roughly how much work it is. Sounds like passing through an argument and putting a conditional somewhere around the upload logic, but not sure if it is that simple
Before we decide to add a flag: is this something that could be negotiated with the server during the initial handshake? (We already negotiate other things, like the digest hash function used by the CAS.)
@tjgq yes, remote-cache can send the max supported cas entry size on getcapablities call, this way we will not need to add any bazel flag (seems better option). but we may need to add new property in the repsonse. https://github.com/bazelbuild/remote-apis/blob/main/build/bazel/remote/execution/v2/remote_execution.proto#L1968
In that case, could you bring this up as a potential addition to the spec by filing an issue at https://github.com/bazelbuild/remote-apis?
Sounds like a better approach indeed
@amishra-u can you please also update the feature request here and assign it to me? (I can't edit) Thx!
@diegohavenstein same here, I don't have permission to assign the task to anyone.
@diegohavenstein I have assigned to you. Thanks!
@coeuvre I am taking over for Diego, he left our team. Can you assign the issue to me?
@axeluhlig are you still interested in fixing this?
@meisterT interested yes, but I am lacking the time to finish this one. Sorry about that. The API change is merged, the required changes in the Bazel client are still missing.
Please unassign me.
@meisterT axeluhlig stepped aside on this one last week, so I would like to pick it up if nobody else has it.
tjgq asked back in 2023 whether this could be negotiated at the handshake rather than being a flag, and that is what happened: max_cas_blob_size_bytes landed in CacheCapabilities and is already vendored in third_party/remoteapis. Nothing in the Java client reads it yet.
What I have locally: CombinedCache resolves the limit lazily from the server capabilities, with --experimental_remote_max_cas_blob_size as an override for servers that advertise nothing. Oversized blobs are skipped in uploadFileToRemote and uploadBlobToRemote, and if an output was skipped the action result is not written to the remote AC, so no dangling entry is left behind. Downloads are untouched, since the proto says a server may still serve larger blobs. Disk cache and remote execution input uploads are unaffected.
Is that the shape you want before I open a PR?
What I have locally: CombinedCache resolves the limit lazily from the server capabilities, with --experimental_remote_max_cas_blob_size as an override for servers that advertise nothing. Oversized blobs are skipped in uploadFileToRemote and uploadBlobToRemote, and if an output was skipped the action result is not written to the remote AC
@gauranshahuja could you share your local changes? I'd like to help develop and review the feature.
I met a problem with large output (about 5 GiB) . it make our remote cache upload expensive.
currently, the workaround is --modify_execution_info=^CppLink$=+no-remote-cache-upload. However, it disables uploads for all CppLink acitons. Actions with small outputs are affected too.
@PikachuHyA sure, here it is: https://github.com/bazelbuild/bazel/compare/master...gauranshahuja:bazel:18449/remote-max-cas-entry-size
One commit, 6 files:
RemoteOptions: new--experimental_remote_max_cas_blob_size(sameByteSizeConverteras--experimental_disk_cache_gc_max_size, default 0).CombinedCache: the effective limit is the flag if it is set, otherwisemax_cas_blob_size_bytesfrom the server'sCacheCapabilities, resolved lazily on first use likeChunking. 0 from both means no limit.uploadFileToRemote/uploadBlobToRemoteskip blobs above it.UploadManifest: an oversized missing output is not uploaded, and the action result then goes to the disk cache only, not the remote AC, so a later remote hit cannot reference a blob the server never received.- Downloads are not filtered, since the proto allows a server to serve larger blobs.
CombinedCacheTest: 7 tests (flag limit, server limit, no limit, flag over server, file upload still writes the disk cache, manifest withholds the remote AC, download over the limit).
For your case that would be --experimental_remote_max_cas_blob_size=1G (uppercase; the converter accepts K/M/G/T): the 5 GiB link outputs stay out of the remote cache, every smaller CppLink output is still uploaded, and the no-remote-cache-upload workaround is not needed.
Two caveats:
- I have not compiled it yet, so treat it as a sketch until I push a build-verified revision.
- One open question:
uploadFileToRemoteskips the check when the server supports chunked uploads, butUploadManifestchecks before uploading and ignores chunking, so the two disagree. For your use case (cost, not a server limit) I think the flag should apply even with chunking, and only the server-advertised limit should exempt chunked uploads. I'll make them consistent once that is settled.
@meisterT does this direction look right to you, and what would you prefer on the chunking question? I'll open the PR once it builds and the tests pass.