Skip to content

bench: published warm build jumped 46 ms → 249 ms — per-command daemon restart mode (#1476), not a code regression #1479

Closed

Description

@zackees

Summary

The published benchmark (benchmark-stats/benchmark.svg, run 36243261636 at 98be282b) shows the fbuild warm build at 249.3 ms. It was ≈46 ms on every earlier main run since 09-17. The cold build fell from ≈2200 ms to 578 ms in the same run.

This is not a code regression in 98be282b or the #1474 / #1475 / #1477 window. The run landed in the intermittent daemon-restart-per-command mode tracked in #1476. In that mode every fbuild invocation shuts down the daemon and respawns it, which adds a fixed ≈200 ms. The same code measured 46 ms warm in a run started one minute later.

Evidence

1. The restart lines predict the warm time exactly

Counted in each run's benchmark.log. On the phases column: per #1476, cold_phases_ms is populated only when a timed command spawns the daemon itself.

run ref daemon binary updated lines fbuild warm fbuild cold phases
36243261636 main 98be282b (published) 9 249.3 578.5 19
36243318874 perf/1468-overlap-phases (contains 98be282b), started 1 min later 0 46.1 426.6 0
36240332345 fix/1467-raw-compile-commands 0 46.8 459.5 0
36239761342 perf/1466-probe-once rerun 0 46.2 423.4 0
36239211262 debug/restart-mtime 0 46.6 443.4 0
36238206814 perf/1466-probe-once 9 251.3 651.7 19
36236358015 perf/1464-repin-zccache rerun 0 46.3 450.7 0
36236206722 debug/1464-warm-restart 0 45.9 659.8 0
36234375809 perf/1464-repin-zccache 9 251.4 675.9 19
36232813750 main 16a94128 (2.5.28) 0 46.4 2611.9 0
36228075783 main 1c0ebfa6 0 45.2 2219.9 0
36185621212 main 5f2afd29 0 46.2 2247.4 0
36118911562 main 0433e964 0 45.9 2111.3 0
35981683520 main 0433e964 0 45.3 2150.4 0
35843306373 main 057408f3 0 47.7 2718.6 0
35079721469 main 35d37229 (09-16, before the zccache repin) 9 249.8 2012.0 0

The correlation is 16/16. In history.jsonl, 6 of 74 main runs sit at ≈249 ms warm: 08-08, 08-11, 08-15, 08-20, 09-16 and 09-26. The mode long predates the zccache / running-process 4.10.14 repin in #1474. Today it just happened to land on the one run that got published.

2. The extra time is outside the build

fbuild-perf.jsonl from the bad run shows the warm avr-orchestrator timer at 8.9 ms total (fast-path-check hit, no compile). All three warm trials are 249.3 / 248.8 / 249.6 ms. A spread that tight points to a fixed wait, not variable work.

3. Where the ≈200 ms comes from

benchmark.log writes each command's stdout, then its stderr. So the daemon binary updated, restarting... line printed below each build ran at the start of that command. ensure_direct_daemon_running (crates/fbuild-cli/src/daemon_client.rs) then:

  1. calls client.shutdown(), then sleep(100ms) → health() until the old daemon is gone (≥ 1 tick = 100 ms);
  2. calls spawn_daemon_process(), then sleep(100ms) → health() until the new one answers (≥ 1 tick = 100 ms).

That is ≈200 ms of fixed poll ticks on every command: 46 + ≈200 ≈ 249 ms. A local run with a stopped daemon shows the spawn half taking exactly one tick: daemon not running, starting... at …39.107, then daemon started successfully at …39.209.

4. It does not reproduce locally

I built 6ff52d27 (the zccache repin) with soldr cargo build --release -p fbuild-cli -p fbuild-daemon and ran repeated fbuild build bench/blink -e uno --release on Linux. Warm is 40 ms with no restart, on both the broker path and RUNNING_PROCESS_DISABLE=1 (direct path). fbuild daemon status reports Binary mtime equal to the on-disk sibling.

New finding: the capture step suggested in #1476 would log nothing

#1476 proposes catching a bad run with RUST_LOG=fbuild_cli=info. daemon_client is compiled into the fbuild binary crate, so its tracing target is fbuild::daemon_client, not fbuild_cli. Verified locally: RUST_LOG=fbuild_cli=info prints nothing, while RUST_LOG=info prints INFO fbuild::daemon_client: daemon not running, starting.... The capture must use RUST_LOG=fbuild=info or fbuild::daemon_client=info, or the next bad run will again yield no mtimes.

Root cause status

Open (#1476). The restart fires when should_restart_daemon sees the same version and the CLI's sibling fbuild-daemon mtime greater than the daemon's source_mtime. The two sides stat different things:

  • the CLI stats current_image_sibling_candidates("fbuild-daemon");
  • the daemon stats its own current_exe(), in crates/fbuild-daemon/src/context.rs::compute_binary_mtime.

Both the preflight daemon restart and the per-command respawn go through the same spawn of that sibling. So a freshly respawned daemon should report the identical mtime, yet the next command still restarts it. That points to one of two things:

  • the /health answer coming from a daemon other than the one just spawned; for example, one the running-process broker respawns on the same derived port after shutdown, which the direct spawn then yields to;
  • the running image differing from the sibling on disk; soldr materializes target/release/fbuild-daemon with link count 2.

Neither can be confirmed without the mtime pair from a bad run.

Proposed actions

  1. Benchmark guard (cheap, stops bad data from publishing): in bench/fastled-examples/src/build_comparison.rs, fail or retry the fbuild series when any timed fbuild command's output contains daemon binary updated. At minimum, record a daemon_restarts count in latest.json so affected points are visible.
  2. Diagnostics: set RUST_LOG=fbuild=info (not fbuild_cli=info) on the benchmark step. Also log the daemon PID and current_exe() in the restart line, so the next bad run tells us which daemon answered.
  3. Fix (per bench: intermittent per-command daemon restart ('daemon binary updated') adds ~200 ms to every fbuild command #1476): compare a build identity (git sha or a build id the daemon reports) instead of raw mtimes from two different files in should_restart_daemon.
  4. Republish: re-dispatch benchmark-build-comparison.yml on main. The good-mode numbers for current code are ≈46 ms warm and ≈420–460 ms cold. The cold improvement from perf(build): repin zccache to 8475316 for the fast miss path (#1464) #1474 / perf(build): probe each toolchain once per daemon (#1466) #1475 is real.

Related: #1476 (restart mode, root cause), #1465 (per-phase timings), #1474 / #1475 / #1477 (the window under suspicion, cleared by the table above).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions