Skip to content

Apply arg_replacements scrubbing to params file cache key hashing#30143

Open
oliviernotteghem wants to merge 1 commit into
bazelbuild:masterfrom
uber-common:scrub_param_files
Open

Apply arg_replacements scrubbing to params file cache key hashing#30143
oliviernotteghem wants to merge 1 commit into
bazelbuild:masterfrom
uber-common:scrub_param_files

Conversation

@oliviernotteghem

Copy link
Copy Markdown

Behavior is conditional to --experimental_remote_scrubbing_param_files_arg_replacements_enabled param

Summary:
Intent:
- The xplat scrubber's arg_replacements rules normalize command-line arguments before they enter the remote cache key, allowing machines with different paths/workspace roots to share cache hits.
- Params files (virtual action inputs written as @params files) were previously hashed using their raw byte content, bypassing the arg_replacements logic entirely.
- This change extends the same normalization to params file content so that the hash used in the Merkle tree reflects the scrubbed arguments, not the raw ones.

Changes:
- CommandLines.ParamFileActionInput: added getType() and getCharset() getters so callers can reconstruct a params file with different arguments.
- DirectoryTreeBuilder.buildFromActionInputs(): when a VirtualActionInput is a ParamFileActionInput and a SpawnScrubber is active, each argument is passed through spawnScrubber.transformArgument() before the digest is computed. The resulting Merkle tree node (both hash and byte content) reflects the scrubbed args, consistent with how regular command-line args are already handled in buildCommand().

Tags: #has_java

Differential Revision: https://code.uberinternal.com/D25337121

Description

Motivation

Build API Changes

No

Checklist

  • I have added tests for the new use cases (if any).
  • I have updated the documentation (if applicable).

Release Notes

RELNOTES: None

Behavior is conditional to --experimental_remote_scrubbing_param_files_arg_replacements_enabled param

Summary:
  Intent:
    - The xplat scrubber's `arg_replacements` rules normalize command-line arguments before
      they enter the remote cache key, allowing machines with different paths/workspace
      roots to share cache hits.
    - Params files (virtual action inputs written as `@params` files) were previously hashed
      using their raw byte content, bypassing the `arg_replacements` logic entirely.
    - This change extends the same normalization to params file content so that the hash
      used in the Merkle tree reflects the scrubbed arguments, not the raw ones.

  Changes:
    - `CommandLines.ParamFileActionInput`: added `getType()` and `getCharset()` getters
      so callers can reconstruct a params file with different arguments.
    - `DirectoryTreeBuilder.buildFromActionInputs()`: when a `VirtualActionInput` is a
      `ParamFileActionInput` and a `SpawnScrubber` is active, each argument is passed
      through `spawnScrubber.transformArgument()` before the digest is computed. The
      resulting Merkle tree node (both hash and byte content) reflects the scrubbed args,
      consistent with how regular command-line args are already handled in `buildCommand()`.

Tags: #has_java

Differential Revision: https://code.uberinternal.com/D25337121
@oliviernotteghem oliviernotteghem requested a review from a team as a code owner July 6, 2026 19:29
@github-actions github-actions Bot added team-Performance Issues for Performance teams team-Remote-Exec Issues and PRs for the Execution (Remote) team awaiting-review PR is awaiting review from an assigned reviewer labels Jul 6, 2026
public abstract boolean getExperimentalRemoteCacheChunking();

@Option(
name = "experimental_remote_scrubbing_param_files_arg_replacements_enabled",

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 wouldn't recommend making this a flag, the old behavior is a straight up bug and experimental features can be changed at will anyway.

scrubbedArgs,
paramFile.getType());
}
var digest = digestUtil.compute(virtualActionInput);

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.

You could avoid eager materialization of all args by adding a writeToTransformed method to ParamFileActionInput that accepts a transformation and then call that function in a lambda DeterminsticWriter in the call to digestUtil.compute below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR is awaiting review from an assigned reviewer team-Performance Issues for Performance teams team-Remote-Exec Issues and PRs for the Execution (Remote) team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants