Repository navigation
Let resource_set callbacks opt into the inputs' total size - #31833
Draft
rdesgroppes wants to merge 1 commit into
Draft
rdesgroppes wants to merge 1 commit into
rdesgroppes wants to merge 1 commit into
Conversation
rdesgroppes
force-pushed
the
resource-set-inputs-bytes
branch
2 times, most recently
from
October 17, 2026 21:14
e96a5fc to
91aea18
Compare
### Description Starlark `resource_set` callbacks declaring an `inputs_bytes` parameter (or `**kwargs`) now also receive the total size in bytes of the action's expanded inputs, as that keyword argument. Other callbacks keep being called with exactly `(os, inputs_size)`. Local runners pass the size lazily to the new `Spawn.getLocalResources(InputsBytes)`, as computed by `SpawnExecutionContext.getInputsBytes()` from the input mapping and metadata they already hold. It's therefore only summed for declarations asking for it, and without downloading inputs. `ResourceSetOrBuilder` gains `needsInputsBytes()` and a 3-argument `buildResourceSet`, both defaulting to the existing behavior, so native estimators are unaffected. Callers without input metadata at hand, such as tests, pass `InputsBytes.UNKNOWN` explicitly. ### Motivation Link steps' memory scales with the bytes they link, which the input count misses for the links most at risk of OOM kills, as measured in bazelbuild#31827. Fixes bazelbuild#31827 ### Build API Changes Yes 1. Discussed in bazelbuild#31827. 2. Backward compatible: callbacks only receive `inputs_bytes` when declaring it (or `**kwargs`). 3. Not a breaking change. ### Checklist - [x] I have added tests for the new use cases (if any). - [x] I have updated the documentation (if applicable). ### Release Notes RELNOTES[NEW]: `resource_set` callbacks declaring an `inputs_bytes` parameter receive the total size in bytes of the action's inputs.
rdesgroppes
force-pushed
the
resource-set-inputs-bytes
branch
from
October 18, 2026 15:47
91aea18 to
22791fd
Compare
This branch has not been deployed
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.
Description
Starlark
resource_setcallbacks declaring aninputs_bytesparameter (or**kwargs) now also receive the total size in bytes of the action's expanded inputs, as that keyword argument. Other callbacks keep being called with exactly(os, inputs_size).Local runners pass the size lazily to the new
Spawn.getLocalResources(InputsBytes), as computed bySpawnExecutionContext.getInputsBytes()from the input mapping and metadata they already hold. It's therefore only summed for declarations asking for it, and without downloading inputs.ResourceSetOrBuildergainsneedsInputsBytes()and a 3-argumentbuildResourceSet, both defaulting to the existing behavior, so native estimators are unaffected. Callers without input metadata at hand, such as tests, passInputsBytes.UNKNOWNexplicitly.Motivation
Link steps' memory scales with the bytes they link, which the input count misses for the links most at risk of OOM kills, as measured in #31827.
Fixes #31827.
Build API Changes
Does this PR affect the Build API? (e.g. Starlark API, providers, command-line flags, native rules)
=> Yes
If yes, please answer the following:
=> Pass the total size in bytes of an action's inputs to Starlark
resource_setcallbacks #31827.=> Backward compatible: callbacks only receive
inputs_byteswhen declaring it (or**kwargs).=> Not a breaking change.
Checklist
Release Notes
RELNOTES[NEW]:
resource_setcallbacks declaring aninputs_bytesparameter receive the total size in bytes of the action's inputs.