[PR #6034] [MERGED] tools: build_times.py measures cold and incremental builds per crate #6618

Closed
opened 2026-11-03 06:23:52 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6034
Author: @mariuslozo-boop
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: tools/build-times


📝 Commits (2)

  • c65cb2b tools: build_times.py measures cold and incremental builds per crate (#5794)
  • e30ff91 docs: build-times.md, how to run tools/build_times.py and the first numbers (#5794)

📊 Changes

4 files changed (+1571 additions, -0 deletions)

View changed files

📝 docs/README.md (+1 -0)
➕ docs/build-times.md (+137 -0)
➕ tests/test_build_times.py (+596 -0)
➕ tools/build_times.py (+837 -0)

📄 Description

🤖 Opened by mariuslozo-boop's AI agent (Claude Code, Claude Sonnet 5.5 + Claude Opus 5.5 review), not by mariuslozo-boop personally.

What and why

Refs #5794 (part of #3916). The crate split needs a build-time number before and after. This adds tools/build_times.py run, which measures that the same way on any checkout, and docs/build-times.md with how to run it and the first numbers. Comparing two reports (compare) is a separate pull request on top of this one, #6035, which closes #5794.

  • run: cargo build --locked -p horizon-client --profile <p> --timings in a target folder of its own (.local/build-times/target-<profile>). It measures a cold build, a build with nothing changed, and an incremental build after a one-line comment in horizon-world, horizon-client-render, horizon-client (game.rs) and horizon-items. Per-crate times and the critical path come from the UNIT_DATA in cargo's timings page, read in both the current and the older (cargo up to 1.92) field names. A dependent that only needs .rmeta waits for its dependency's frontend, not the whole unit.
  • Report: JSON plus a Markdown table with the commit, OS, CPU, RAM, rustc and cargo versions, jobs and where they came from, build variables, the edited file:line and every warning.
  • Safety:
    • It refuses a dirty tree unless --allow-dirty is given, which the report records.
    • It only empties a folder holding its own marker, never target/, and its --target-dir beats CARGO_TARGET_DIR.
    • The edited file and its modification time are put back on an error, Ctrl+C, SIGTERM or Ctrl+Break.
    • If the run is killed, a note lets the next run restore the file first. A file that something else wrote in the meantime (an editor) is left alone and the run stops.
  • Skew: another cargo, rustc or linker process, or a CPU more than 15% busy before a build, is warned about and kept beside that number.

First numbers (Ryzen 7 7700X, 16 threads; seconds; dev median of 3):

Build Windows dev Linux (WSL2) dev Windows fast Linux fast
Cold 106.6 99.9 235.6 184.7
Nothing changed 0.4 0.2 0.4 0.2
horizon-world edit 21.4 22.0 29.5 60.5
horizon-client-render edit 15.8 12.2 78.3 51.6
game.rs edit 14.4 10.6 92.3 60.6
horizon-items edit 23.1 19.0 127.5 83.8

The cold dev build ends with horizon-client the library (21 s) and then the binary (35 s), with almost nothing running beside them: a third of the build is one rustc on one crate.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

none

Other projects' code

none (the older timings field names were checked against cargo's own source, 0.86 to 0.94; nothing copied)

Self-check

tests/test_build_times.py: 45 tests with a fake cargo and a throwaway git repository. They cover the critical-path walk, .rmeta waits, both timings formats, each edit mode, the put-back on errors and Ctrl+C, the restore note after a kill (and leaving a file alone that something else wrote), the dirty-tree refusal, the target-folder marker, --locked, --target-dir, jobs, warnings and report names. About 30 deliberate breaks of the tool (made before the split) each failed at least one test.

Real runs on Windows:

  • The full runs that gave the numbers above.
  • A hard kill mid-edit: the next run restored gfx.rs and git status was clean.
  • After the review fixes, a short real run (--only incremental --profiles dev --crates horizon-client-render,horizon-items): it built, wrote both reports, and left the tree clean.

pr_ready (tools/pr_ready.py --base upstream/main on PCDKBLENDER, against upstream/main at c05ef84a5, 1 min 19 s)

Check Result
Scope ⚠️ 4 files, +1571 −0; 837 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 570 passed (1 min 17 s)
rustfmt ➖ no Rust change
clippy ➖ no Rust change
tests ➖ no crate touched
doc tests ➖ no crate touched
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ❌ 375 affected,
Label skip-release
  • Scope: not split further. Most of it is the put-back safety, the skew warnings and the two timings formats, which the numbers depend on. compare is already split off into #6035.
  • Parity: run on Windows, where the runner needs fcntl and can't start. No harness touches this tool.
  • RUST_TEST_THREADS=2 was set (no Rust change here, so it changed nothing).

Not tested:

  • macOS (the ps, sysctl and load-average paths) and bare-metal Linux: Linux was WSL2 with 8 GB.
  • The release profile; one cold run per profile and machine, so no spread for cold builds.
  • The older cargo format on a real old cargo: tested with pages built from the field names in cargo's source.
  • A real Ctrl+C or SIGTERM: only an exception mid-build in the tests, and a hard kill by hand.
  • The Windows machine had the Unreal Editor open, so its numbers carry some noise (the doc lists its busy-CPU warnings, 16.6% to 25.6%).

Known limits: a kill stops cargo but rustc may run on into the tool's own target folder; two runs on one checkout at once aren't prevented; [build] jobs in a cargo config file isn't detected. In items.rs the middle edit finds no item to go before, so it goes on line 1 and the report says so.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RodDbPWCByh96WKcbiEQpB


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/6034 **Author:** [@mariuslozo-boop](https://github.com/mariuslozo-boop) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `tools/build-times` --- ### 📝 Commits (2) - [`c65cb2b`](https://github.com/horizon-rust/horizon/commit/c65cb2b9295c88e94a8c09d3518121f9c99385f4) tools: build_times.py measures cold and incremental builds per crate (#5794) - [`e30ff91`](https://github.com/horizon-rust/horizon/commit/e30ff91de7157c697ab86a6602a2336532c8da71) docs: build-times.md, how to run tools/build_times.py and the first numbers (#5794) ### 📊 Changes **4 files changed** (+1571 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/README.md` (+1 -0) ➕ `docs/build-times.md` (+137 -0) ➕ `tests/test_build_times.py` (+596 -0) ➕ `tools/build_times.py` (+837 -0) </details> ### 📄 Description > 🤖 Opened by mariuslozo-boop's AI agent (Claude Code, Claude Sonnet 5.5 + Claude Opus 5.5 review), not by mariuslozo-boop personally. ## What and why Refs #5794 (part of #3916). The crate split needs a build-time number before and after. This adds `tools/build_times.py run`, which measures that the same way on any checkout, and `docs/build-times.md` with how to run it and the first numbers. Comparing two reports (`compare`) is a separate pull request on top of this one, #6035, which closes #5794. - **`run`:** `cargo build --locked -p horizon-client --profile <p> --timings` in a target folder of its own (`.local/build-times/target-<profile>`). It measures a cold build, a build with nothing changed, and an incremental build after a one-line comment in `horizon-world`, `horizon-client-render`, `horizon-client` (`game.rs`) and `horizon-items`. Per-crate times and the critical path come from the `UNIT_DATA` in cargo's timings page, read in both the current and the older (cargo up to 1.92) field names. A dependent that only needs `.rmeta` waits for its dependency's frontend, not the whole unit. - **Report:** JSON plus a Markdown table with the commit, OS, CPU, RAM, rustc and cargo versions, jobs and where they came from, build variables, the edited `file:line` and every warning. - **Safety:** - It refuses a dirty tree unless `--allow-dirty` is given, which the report records. - It only empties a folder holding its own marker, never `target/`, and its `--target-dir` beats `CARGO_TARGET_DIR`. - The edited file and its modification time are put back on an error, Ctrl+C, SIGTERM or Ctrl+Break. - If the run is killed, a note lets the next run restore the file first. A file that something else wrote in the meantime (an editor) is left alone and the run stops. - **Skew:** another cargo, rustc or linker process, or a CPU more than 15% busy before a build, is warned about and kept beside that number. First numbers (Ryzen 7 7700X, 16 threads; seconds; dev median of 3): | Build | Windows dev | Linux (WSL2) dev | Windows fast | Linux fast | |---|---|---|---|---| | Cold | 106.6 | 99.9 | 235.6 | 184.7 | | Nothing changed | 0.4 | 0.2 | 0.4 | 0.2 | | `horizon-world` edit | 21.4 | 22.0 | 29.5 | 60.5 | | `horizon-client-render` edit | 15.8 | 12.2 | 78.3 | 51.6 | | `game.rs` edit | 14.4 | 10.6 | 92.3 | 60.6 | | `horizon-items` edit | 23.1 | 19.0 | 127.5 | 83.8 | The cold dev build ends with `horizon-client` the library (21 s) and then the binary (35 s), with almost nothing running beside them: a third of the build is one rustc on one crate. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [x] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference none ## Other projects' code none (the older timings field names were checked against cargo's own source, 0.86 to 0.94; nothing copied) ## Self-check `tests/test_build_times.py`: 45 tests with a fake cargo and a throwaway git repository. They cover the critical-path walk, `.rmeta` waits, both timings formats, each edit mode, the put-back on errors and Ctrl+C, the restore note after a kill (and leaving a file alone that something else wrote), the dirty-tree refusal, the target-folder marker, `--locked`, `--target-dir`, jobs, warnings and report names. About 30 deliberate breaks of the tool (made before the split) each failed at least one test. Real runs on Windows: - The full runs that gave the numbers above. - A hard kill mid-edit: the next run restored `gfx.rs` and `git status` was clean. - After the review fixes, a short real run (`--only incremental --profiles dev --crates horizon-client-render,horizon-items`): it built, wrote both reports, and left the tree clean. **pr_ready** (`tools/pr_ready.py --base upstream/main` on PCDKBLENDER, against upstream/main at c05ef84a5, 1 min 19 s) | Check | Result | | --- | --- | | Scope | ⚠️ 4 files, +1571 −0; 837 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 570 passed (1 min 17 s) | | rustfmt | ➖ no Rust change | | clippy | ➖ no Rust change | | tests | ➖ no crate touched | | doc tests | ➖ no crate touched | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ❌ 375 affected, | | Label | `skip-release` | - Scope: not split further. Most of it is the put-back safety, the skew warnings and the two timings formats, which the numbers depend on. `compare` is already split off into #6035. - Parity: run on Windows, where the runner needs `fcntl` and can't start. No harness touches this tool. - `RUST_TEST_THREADS=2` was set (no Rust change here, so it changed nothing). Not tested: - macOS (the `ps`, `sysctl` and load-average paths) and bare-metal Linux: Linux was WSL2 with 8 GB. - The `release` profile; one cold run per profile and machine, so no spread for cold builds. - The older cargo format on a real old cargo: tested with pages built from the field names in cargo's source. - A real Ctrl+C or SIGTERM: only an exception mid-build in the tests, and a hard kill by hand. - The Windows machine had the Unreal Editor open, so its numbers carry some noise (the doc lists its busy-CPU warnings, 16.6% to 25.6%). Known limits: a kill stops cargo but rustc may run on into the tool's own target folder; two runs on one checkout at once aren't prevented; `[build] jobs` in a cargo config file isn't detected. In `items.rs` the `middle` edit finds no item to go before, so it goes on line 1 and the report says so. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01RodDbPWCByh96WKcbiEQpB --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:23:52 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#6618
No description provided.