remoting: check action cache for cached result before submitting a request #10253
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.
Problem
The REv2 specification does not explicitly require servers to return cached results from the
Execute
method of theExecution
service. The specification hints that servers might do so, but stops short of actually mandating it, stating that:The RE client in Pants does not currently call
GetActionResult
to check for cached results before submitting an execution request. This is not problematic if the server checks the cache and short-circuitsExecute
calls with any cached results. This may be the case for RBE, but is intentionally not the case for BuildBarn. Bazel always callsGetActionResult
, and so the BuildBarn team determined it to be duplicative to haveExecute
also check the cache a second time (which would negatively impact performance). (I have not audited what Buildgrid and Buildfarm do.) See discussion at https://buildteamworld.slack.com/archives/CD6HZC750/p1593720268111500.Thus, at least when submitting work to BuildBarn, Pants will not take advantage of the Action Cache and the server will redo work that has already been performed and stored in the Action Cache.
Solution
Pants should call
GetActionResult
to check for a cached result before it attempts to upload and submit theAction
andCommand
protos for execution.Testing: The test framework's mock server now answers
GetActionResult
requests. The new testsuccessful_served_from_action_cache
tests that Pants checks the Action Cache first. (The other unit tests handle the fact that GetActionResult calls are made, but assume nothing was cached.)Result
I used an early iteration of this PR to run tests of Toolchain's internal repo against BuildBarn. With this PR, the second run is cached and completes in about a minute. Without this PR, that run actually submits execution requests and duplicates work with a significant impact on build performance.