From ff35ee4a2073848cd2fe5b5b88a495a844b3c6e1 Mon Sep 17 00:00:00 2001 From: Albert Lloveras Date: Thu, 17 Sep 2026 07:15:33 +0000 Subject: [PATCH] fix(stamping): skip build data spawn when --stamp=false (#4160) ## Summary `PyWriteBuildData` is dirty on every build with a cold Skyframe when outputs are not downloaded. That is, once per `py_binary` and `py_test` in 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=minimal` the 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_regex` to 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 `stat` syscalls) for none of the benefits. ## Change When `is_stamping_enabled(ctx)` is false, the content of the file is known at analysis time: ``` TARGET