Summary
run sweep recomputes identical build/environment metadata for every successful point. In a small 11-point 1D sweep, metadata collection took far longer than all eleven solves and spawned 22 Git subprocesses.
A command-scoped build snapshot prototype reduced the warm sweep median from 299.49 ms to 25.90 ms (11.56x) while retaining one ordinary artifact per point.
Measured on public main at 5100ab00cb8b2aa5d43682ab0e9b871bee8f7ac1 on an Apple-silicon CPU.
Profile
For an 11-point 1D sweep from 0.20 V through 0.40 V:
_run_sweep 0.470 s
artifact.write_run 0.325 s
artifact.environment 0.302 s
artifact.git_commit 0.275 s
all 11 solver calls combined 0.018 s
artifact.write_run() currently performs this for every point:
env = environment()
build = code_id(env)
environment() hashes the same imported package source and calls both git rev-parse HEAD and git status --porcelain -- src. Eleven successful points therefore run the same source scan eleven times and spawn 22 Git subprocesses.
Benchmark
Seven warm samples, medians:
current per-point metadata: 299.494 ms
one snapshot per sweep: 25.903 ms
speedup: 11.56x
Suggested direction
Compute an immutable environment/build snapshot once at the start of _run_sweep and pass it to every write_run() call. Keep write_run()'s current self-computing default for standalone callers so its API remains safe outside a command-scoped batch.
This is preferable to an unbounded module-global cache: a later independent command must see source or environment changes.
Semantic decision to make explicit
A long-running sweep could overlap with a source/worktree change. Define whether all points belong to the build observed when the command started, or whether such a change should abort the sweep. Whichever policy is chosen, every artifact in one successful sweep should carry a deliberate, tested build contract rather than inheriting timing from repeated subprocess calls.
Regression coverage
- Assert environment/source/Git discovery runs once per sweep, not once per point.
- Assert every point records the same environment and
code_id snapshot.
- Assert a standalone
write_run() still computes a fresh snapshot by default.
- Keep artifact contents, checksums, run IDs, and compare semantics unchanged.
Summary
run sweeprecomputes identical build/environment metadata for every successful point. In a small 11-point 1D sweep, metadata collection took far longer than all eleven solves and spawned 22 Git subprocesses.A command-scoped build snapshot prototype reduced the warm sweep median from
299.49 msto25.90 ms(11.56x) while retaining one ordinary artifact per point.Measured on public
mainat5100ab00cb8b2aa5d43682ab0e9b871bee8f7ac1on an Apple-silicon CPU.Profile
For an 11-point 1D sweep from 0.20 V through 0.40 V:
artifact.write_run()currently performs this for every point:environment()hashes the same imported package source and calls bothgit rev-parse HEADandgit status --porcelain -- src. Eleven successful points therefore run the same source scan eleven times and spawn 22 Git subprocesses.Benchmark
Seven warm samples, medians:
Suggested direction
Compute an immutable environment/build snapshot once at the start of
_run_sweepand pass it to everywrite_run()call. Keepwrite_run()'s current self-computing default for standalone callers so its API remains safe outside a command-scoped batch.This is preferable to an unbounded module-global cache: a later independent command must see source or environment changes.
Semantic decision to make explicit
A long-running sweep could overlap with a source/worktree change. Define whether all points belong to the build observed when the command started, or whether such a change should abort the sweep. Whichever policy is chosen, every artifact in one successful sweep should carry a deliberate, tested build contract rather than inheriting timing from repeated subprocess calls.
Regression coverage
code_idsnapshot.write_run()still computes a fresh snapshot by default.