Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed .regen-probe-untracked
Empty file.
24 changes: 15 additions & 9 deletions dag/gunbc/regen_round_cost.dag
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import std.observation { TimedMeasurement, Measured, MeasuredValue, MeasuredUnav
type RegenRoundPhase
= SeedBuild
| CorpusLoad
| CorpusReload
| Frontend
| Normalize
| Reconcile
Expand Down Expand Up @@ -105,8 +104,9 @@ type RegenRoundCostReceipt {
host: String
tree: String
tree_dirty: Bool
seed_build_compiled_crates: Int
rebuild_compiled_crates: Int
seed_build_compiled_crates: Nat
rebuild_compiled_crates: Nat
rustfmt_spawns: Nat
marks: List<TraceMark>
changed_paths: List<String>
}
Expand All @@ -115,7 +115,6 @@ fn regen_round_phase_tag(phase: RegenRoundPhase) -> String {
match phase {
SeedBuild => "seed_build"
CorpusLoad => "corpus_load"
CorpusReload => "corpus_reload"
Frontend => "compile.frontend"
Normalize => "compile.normalize"
Reconcile => "compile.reconcile"
Expand All @@ -141,7 +140,6 @@ fn regen_round_phase_label(phase: RegenRoundPhase) -> String {
match phase {
SeedBuild => "round.seed_build"
CorpusLoad => "regen.corpus_load"
CorpusReload => "regen.corpus_reload"
Frontend => "compile.frontend"
Normalize => "compile.normalize"
Reconcile => "compile.reconcile"
Expand All @@ -159,7 +157,7 @@ fn regen_round_phase_label(phase: RegenRoundPhase) -> String {
}

fn regen_round_phases() -> List<RegenRoundPhase> {
[SeedBuild, CorpusLoad, CorpusReload, Frontend, Normalize, Reconcile, Analyses, Emit, MirrorWrite, CandidateVerify, Adjudicate, HandVerify, Digest, Install, RebuildFromInstalled, Diff]
[SeedBuild, CorpusLoad, Frontend, Normalize, Reconcile, Analyses, Emit, MirrorWrite, CandidateVerify, Adjudicate, HandVerify, Digest, Install, RebuildFromInstalled, Diff]
}

fn regen_round_phase_of_label(label: String) -> RegenRoundPhaseAttribution {
Expand Down Expand Up @@ -217,7 +215,10 @@ fn regen_round_header_line(receipt: RegenRoundCostReceipt) -> String {
concat(concat(" tree=", receipt.tree), concat(" tree_dirty=", regen_round_bool_text(b: receipt.tree_dirty))),
concat(
concat(" seed_build_compiled_crates=", to_string(receipt.seed_build_compiled_crates)),
concat(" rebuild_compiled_crates=", to_string(receipt.rebuild_compiled_crates))
concat(
concat(" rebuild_compiled_crates=", to_string(receipt.rebuild_compiled_crates)),
concat(" rustfmt_spawns=", to_string(receipt.rustfmt_spawns))
)
)
)
)
Expand Down Expand Up @@ -308,6 +309,11 @@ data regen_affected_set_disposition: AffectedSetDisposition = DerivableNow {
// a round with a real edit; the two cargo builds of the seed (before the round, and
// rebuild-from-installed) are the majority of such a round even for a one-mirror change,
// because every mirror compiles into one crate and cargo recompiles that crate whole; the
// corpus is read twice (corpus_load then corpus_reload, the second inside compile_stage0) and
// rustfmt normalizes the whole population three times (mirror_write, adjudicate, digest).
// corpus WAS read twice (corpus_load then a corpus_reload inside compile_stage0) and rustfmt
// normalized the whole population three times (mirror_write, adjudicate, digest) -- both
// closed in the change after the measurement: one read threaded to both consumers, and one
// normalize per distinct input through a memo plus a per-rustfmt-version disk cache under
// target/stage0-regen-rustfmt-cache whose entries are honoured only when the stored raw input
// is byte-equal to the request. rustfmt_spawns on the receipt is the count the fixed-point
// control is checked against.
data regen_round_cost_shape_note: String = "The instrument, not the number: re-run `claim_executor --regen-round-cost --source-root dag --source-root src/v2` on a tree and read its receipt (target/stage0-regen-round-cost.txt). A change-denominated regen is bounded above by the reverse closure (regen_affected_set_disposition); a change-denominated REBUILD is bounded below by one whole-crate compile until the stage0 partition (gunbc.stage0_crate_partition_generated) carries the mirrors, which is the larger of the two costs on every measured host."
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module test.claim.regen_round_cost_witness
module test.claim.self_host_regen_round_cost_witness

import std.types { Bool, String, List, NonEmptyStr }
import std.measure { CpuClock, WallClock, Nanosecond, nanosecond, nanosecond_count }
Expand Down Expand Up @@ -46,6 +46,7 @@ fn a_receipt(marks: List<TraceMark>) -> RegenRoundCostReceipt {
tree_dirty: false,
seed_build_compiled_crates: 0,
rebuild_compiled_crates: 2,
rustfmt_spawns: 7,
marks: marks,
changed_paths: ["v1_rt.rs", "v1_compiler_runtime_rust.rs"]
}
Expand Down Expand Up @@ -135,7 +136,7 @@ test fn a_receipt_renders_provenance_marks_totals_and_changed_paths() -> Bool {
a_mark(label: "compile.emit", wall_ms: 300000, cpu_ms: 299000)
]))
text == concat(
"regen-round-cost: producer=claim_executor --regen-round-cost host=srv1 tree=2a11b317d2caf3c37d1d38a4421e8e0c06188925 tree_dirty=false seed_build_compiled_crates=0 rebuild_compiled_crates=2\n",
"regen-round-cost: producer=claim_executor --regen-round-cost host=srv1 tree=2a11b317d2caf3c37d1d38a4421e8e0c06188925 tree_dirty=false seed_build_compiled_crates=0 rebuild_compiled_crates=2 rustfmt_spawns=7\n",
concat(
"regen-round-cost: phase=seed_build wall_ms=1500 cpu_ms=9000\nregen-round-cost: phase=compile.emit wall_ms=300000 cpu_ms=299000\n",
"regen-round-cost: total wall_ms=301500 cpu_ms=308000\nregen-round-cost: changed_paths=2 [v1_rt.rs, v1_compiler_runtime_rust.rs]\n"
Expand Down
13 changes: 12 additions & 1 deletion src/v1/stage0/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@ use std::path::Path;
use std::process::Command;

fn git_output(args: &[&str]) -> Option<String> {
let out = Command::new("git").args(args).output().ok()?;
// NO OPTIONAL LOCKS: `git status` refreshes `.git/index` as a side effect, and this script
// watches that path (`rerun-if-changed` below). Refreshing it DURING the script's own run
// made the NEXT build see a changed input, rerun the script and recompile the whole crate
// with nothing changed -- measured 2026-08-30 on srv1 (tree fce29f50, quiescent worktree):
// cold 444 s, then a no-change build 382 s, then 0 s only once the index had settled; and
// inside every `--regen-round-cost` round, seed_build and rebuild-from-installed each
// recompiled the crate at changed_paths=0. `--no-optional-locks` makes the read a read.
let out = Command::new("git")
.arg("--no-optional-locks")
.args(args)
.output()
.ok()?;
if out.status.success() {
Some(String::from_utf8_lossy(&out.stdout).trim().to_string())
} else {
Expand Down
Loading
Loading