Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Address the two moderate compatibility findings.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR avoids unnecessary build-data writer spawns when stamping is disabled while preserving stamped-build behavior.
Changes:
- Writes unstamped build data directly during analysis.
- Retains constant metadata handling for stamped builds.
- Reuses the build-data output across both paths.
File summaries
| File | Summary | Findings |
|---|---|---|
python/private/py_executable.bzl |
Updates build-data generation based on stamping status. | Two moderate findings: use str(ctx.label) for canonical labels and preserve platform-appropriate newline and final-newline behavior (2 votes; 1 vote). |
Review details
Suppressed comments (1)
python/private/py_executable.bzl:1651
- This branch is not byte-identical to the old writer on all supported configurations. The old action uses
str(ctx.label)(the canonical@@...form under bzlmod) and the PowerShell writer emits platform newlines, while multilineArgsrenders the Label display form and uses LF. Materialize the canonical label and a platform-appropriate separator, including the final newline.
content = ctx.actions.args()
.set_param_file_format("multiline")
.add(ctx.label, format = "TARGET %s")
.add("STAMPED FALSE"),
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
alloveras
force-pushed
the
alloveras-fix-unstamped-pywritebuilddata
branch
from
September 14, 2026 13:57
8dbe682 to
e4a37c4
Compare
Collaborator
|
LGTM, but please add a Thank you for the fix! |
Contributor
Author
I added the |
alloveras
force-pushed
the
alloveras-fix-unstamped-pywritebuilddata
branch
from
September 16, 2026 08:53
6c4dbcb to
699804a
Compare
aignas
approved these changes
Sep 16, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Sep 16, 2026
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
PyWriteBuildDatais dirty on every build with a cold Skyframe when outputs are not downloaded. That is, once perpy_binaryandpy_testin the build. When stamping is off, the output is a constant, so the action spawn is pure overhead.Root Cause Analysis
The output is declared with
_py_builtins.declare_constant_metadata_file. Constant metadata always reports itself as unchanged, so Bazel cannot validate it from the action cache. It stats the output on disk instead.Under
--remote_download_outputs=minimalthe output is not on disk. The stat fails and the action is dirty. It re-executes, hits the remote cache, is still not downloaded, and is dirty again on the next cold-server build. Setting--remote_download_regexto match the file avoids this, at the cost of downloading it, which confirms the stat is the trigger.The use of a constant metadata file is justified (as per the comment in the code). With stamping on, the action reads
volatile-status.txt, which changes every build. The build data file is in the binary's runfiles, so without it its consumers would invalidate on every build due to timestamps.However, with stamping off, there is no volatile input. There is nothing to shield. Unfortunately, the current implementation keeps the additional cost (constant metadata being always unchanged plus failed
statsyscalls) for none of the benefits.Change
When
is_stamping_enabled(ctx)is false, the content of the file is known at analysis time:So declare an ordinary output and write it with
ctx.actions.write. No spawn, and no constant metadata output.Note this is broader than
--nostamp.is_stamping_enabledis also false for the exec configuration and forstamp = 0, so tool-config binaries benefit from the fix even when--stamp=trueis set at the top level.The stamped path is unchanged and keeps its constant metadata output.
Compatibility
The output is byte-identical. The label is written with
str(ctx.label)to match"TARGET": str(ctx.label)in the spawn's env, which yields the canonical@@//pkg:targetform.ctx.actions.args().add(ctx.label)renders the display form and drops the@@.After the change, the tests in
tests/build_data/build_data_test.pypass without any modifications.Alternative considered
Keeping the spawn and declaring an ordinary output would also fix the dirtiness. Writing at analysis time is lighter, since it needs no subprocess.
Environment
rules_python 2.2.0, Bazel 9.2.0, Linux. Reproduce with
--remote_download_outputs=minimalagainst a warm remote cache, thenbazel shutdownand rebuild.