[PR #3870] [MERGED] Launcher: native rebuilds stay on the instance's Horizon, in its instance, fast #5261

Closed
opened 2026-11-03 05:11:21 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3870
Author: @levzzz5154
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @levzzz5154

Base: main ← Head: launcher/native-builds-stay-put


📝 Commits (5)

  • 647ec89 Launcher: native rebuilds stay on the instance's Horizon and in its instance
  • abeb584 Launcher: native builds use the fast profile, at low priority
  • e9b2bde Merge remote-tracking branch 'hr/main' into launcher/native-builds-stay-put
  • e06a5ce Merge main into native-builds-stay-put (version-mismatch build option alongside base_for)
  • d33d377 Merge main into launcher/native-builds-stay-put; review fixes

📊 Changes

9 files changed (+542 additions, -195 deletions)

View changed files

📝 docs/launcher-commands.md (+3 -2)
📝 docs/native-mods.md (+61 -18)
📝 launcher/Cargo.lock (+1 -0)
📝 launcher/Cargo.toml (+3 -0)
📝 launcher/src/cli.rs (+27 -22)
📝 launcher/src/main.rs (+4 -12)
📝 launcher/src/native_mods.rs (+277 -130)
📝 launcher/src/process.rs (+6 -1)
📝 launcher/src/rust_toolchain.rs (+160 -10)

📄 Description

🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 themselves.

Native rebuilds become incremental and stay in the instance the mods are installed in. First of the native-mods rework PRs; the UI (Update button, status on the Mods page) comes later.

What changes

  • Rebuilds keep the instance's Horizon. A build starts from the version the instance plays (native_mods::base_for). When that is a native-* build, the next one compiles its recorded revision (native-mods.json's horizon) from its own game files, so the build no longer moves to the newest installed release or Nightly and recompiles everything. Mods that pin a revision still win, as before.

    • Update is explicit: native-build --update starts from the newest installed release or Nightly.
    • native_mods::update_for(version, installed) -> Option<String> returns the newer base a later UI PR can offer as "Update".
    • native-mods.json's base stays the original release or Nightly across rebuilds.
  • Same instance. The build pins meta.version of the instance the mods are in, including the default Horizon instance. The hidden "Native mods" instance, instance_on and carry_settings are gone.

    • Old "Native mods" instances are ordinary Own instances with a pinned version, so they keep working with their data.
    • I checked the auto-update for a pinned default instance:
      • an update changes only Settings::selected, not an instance's pin;
      • stale_versions prunes only release tags (is_game_tag), and nightly::after_update only Nightlies;
      • so a pinned native-* build is neither replaced nor pruned.
  • Clean build environment. Toolchain::command drops RUSTFLAGS, CARGO_ENCODED_RUSTFLAGS, RUSTDOCFLAGS, CARGO_ENCODED_RUSTDOCFLAGS, CARGO_INCREMENTAL, CARGO_PROFILE_*, CARGO_BUILD_*, CARGO_TARGET_*, plus the existing rustup and wrapper variables. It also starts Cargo from the root of the disk the launcher's data is on, and the game's build passes --manifest-path. Why:

    • Cargo reads .cargo/config.toml from its working directory and every directory above it, whatever CARGO_HOME is, so from under $HOME it would read ~/.cargo/config.toml. No flag turns that search off.
    • Overriding keys one by one doesn't work. CARGO_BUILD_RUSTFLAGS="" loses to target.<triple>.rustflags, and config [profile] keys can't all be listed.
    • Starting outside the home leaves none of the player's config files in the search. The source's own .cargo/config.toml, if a revision ever has one, is passed with --config.
  • Kept builds. prune keeps the 3 newest native-* builds that no instance plays, by .installed mtime. Reusing a build touches it.

  • fast profile. Builds use the workspace's fast profile (lto = false, codegen-units = 16, incremental = true) when the pinned source's Cargo.toml has one, else release. native-mods.json records which (profile).

    • PROFILE is part of the variant key, so release-built variants from before this PR won't match: the first build after updating the launcher compiles once.
  • Low priority. The game's cargo build and horizon-mixins' cargo install run at low priority, so the desktop doesn't freeze while they compile (rust_toolchain::low_priority):

    • Unix: nice 19 through setpriority in pre_exec, plus the idle I/O class on Linux (ioprio_set);
    • Windows: BELOW_NORMAL_PRIORITY_CLASS.

    Parallelism stays at Cargo's default, and CARGO_BUILD_JOBS is the one CARGO_BUILD_* variable that still passes through, since it changes no flag. horizon-threads only sets thread priorities, so it had nothing to reuse here. This adds libc for Unix, which was already in the lockfile.

  • Fix found while measuring. A native build's version folder had horizon-ctl, horizon-server and horizon-prepare without the executable bit, because a reflink clone is a new 0644 file. install now copies the permissions.

  • Docs: docs/native-mods.md covers rebuilds, the default instance, pruning, the clean environment, the profile, the priority and the new measurements. docs/launcher-commands.md is regenerated.

launcher/src/backend.rs is not touched.

Measured

Linux x86_64 desktop, isolated launcher home, Nightly 6f8c7a0, Zoom 2.0.0 + FPS Counter 2.0.0 from the registry, nice -n 19 ionice -c 3 horizon-launcher native-build --trust-native-code with CARGO_BUILD_JOBS=10, fast profile:

Step Wall time Crates compiled (native/build.log)
First build (downloads Rust, builds horizon-mixins, the whole game) 4 min 29 s (game compile 3 min 6 s) 384
FPS Counter off, rebuild 56 s (compile 51 s) 1: horizon-client
FPS Counter on again under 1 s: the kept build is played again 0
Nothing changed, rebuild 1 s 0
Zoom off, rebuild 57 s (compile 51 s) 1: horizon-client

An earlier run of the same steps used the release profile, without nice and without a jobs cap:

Step release
First build 7 min 6 s (game compile 5 min 0 s)
Each rebuild 2 min 34 s (2 min 28 s compiling horizon-client)
Re-enable, and unchanged 0–1 s

So a rebuild recompiles only horizon-client, the crate the mixins touch. Nothing else is rebuilt, so there was no cause to chase.

FPS. I compared the fast native build (FPS Counter on) with the Nightly's own CI release binary. Setup: horizon-ctl launch --offscreen, a new creative world with seed 12345, 40 s to load, then bench 20. Both ran at nice 19, alternating, two runs each.

FPS CPU frame time, avg CPU p99 GPU avg
fast 111.1 / 112.9 0.57 / 0.68 ms 1.42 / 1.87 ms 0.80 / 0.84 ms
release 111.9 / 112.2 0.54 / 0.51 ms 1.39 / 1.24 ms 0.73 / 0.93 ms

FPS is vsync-bound at 120 Hz, so both are the same. CPU time per frame is about 0.1 ms (~15%) higher with fast. This is rough: one spot, and the fast build also draws the FPS overlay.

Checks

  • cd launcher && cargo +stable fmt --check && cargo +stable clippy --all-targets -- -D warnings && cargo +stable test: 280 + 46 + 4 passed.
  • New tests:
    • a_rebuild_stays_on_the_instances_horizon_until_an_update
    • the_newest_builds_no_instance_plays_are_kept
    • the_game_compiles_outside_the_players_cargo_configuration
    • the_players_compiler_settings_stay_out_of_builds
    • builds_use_the_fast_profile_where_the_source_has_it
    • builds_run_at_the_lowest_priority (Linux: nice 19 and the idle I/O class, read back)

pr_ready (tools/pr_ready.py --quick --base hr/main on cachyos-x8664, against hr/main at 7ebf7d26c, 43 s)

Check Result
Scope ⚠️ 8 files, +506 −179; 603 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ changes with a Cargo.toml
Public tree ✅
Python tests ✅ 423 passed (25 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 ✅ (1 s)
launcher clippy ✅ (6 s)
launcher tests ✅ 280 passed (11 s)
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

It is 603 lines of code, about 250 of them tests. The parts depend on each other (the base choice, the instance, the prune and the profile), so I kept them in one PR.

🤖 Generated with Claude Code


🔄 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/3870 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `launcher/native-builds-stay-put` --- ### 📝 Commits (5) - [`647ec89`](https://github.com/horizon-rust/horizon/commit/647ec89bfc39688c0703bd1444c1db57ea3627dc) Launcher: native rebuilds stay on the instance's Horizon and in its instance - [`abeb584`](https://github.com/horizon-rust/horizon/commit/abeb5845dda475c2be0619a0f65f7115c5ec82a6) Launcher: native builds use the fast profile, at low priority - [`e9b2bde`](https://github.com/horizon-rust/horizon/commit/e9b2bdef241612451eca720c63672fce1ac3fb0b) Merge remote-tracking branch 'hr/main' into launcher/native-builds-stay-put - [`e06a5ce`](https://github.com/horizon-rust/horizon/commit/e06a5ced37fd6ac6019c10a1ec3f478bf2a9f0d2) Merge main into native-builds-stay-put (version-mismatch build option alongside base_for) - [`d33d377`](https://github.com/horizon-rust/horizon/commit/d33d377090da1bb1393453619e5aab73eabc1e26) Merge main into launcher/native-builds-stay-put; review fixes ### 📊 Changes **9 files changed** (+542 additions, -195 deletions) <details> <summary>View changed files</summary> 📝 `docs/launcher-commands.md` (+3 -2) 📝 `docs/native-mods.md` (+61 -18) 📝 `launcher/Cargo.lock` (+1 -0) 📝 `launcher/Cargo.toml` (+3 -0) 📝 `launcher/src/cli.rs` (+27 -22) 📝 `launcher/src/main.rs` (+4 -12) 📝 `launcher/src/native_mods.rs` (+277 -130) 📝 `launcher/src/process.rs` (+6 -1) 📝 `launcher/src/rust_toolchain.rs` (+160 -10) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 themselves. Native rebuilds become incremental and stay in the instance the mods are installed in. First of the native-mods rework PRs; the UI (Update button, status on the Mods page) comes later. ## What changes - **Rebuilds keep the instance's Horizon.** A build starts from the version the instance plays (`native_mods::base_for`). When that is a `native-*` build, the next one compiles its recorded revision (`native-mods.json`'s `horizon`) from its own game files, so the build no longer moves to the newest installed release or Nightly and recompiles everything. Mods that pin a revision still win, as before. - **Update** is explicit: `native-build --update` starts from the newest installed release or Nightly. - `native_mods::update_for(version, installed) -> Option<String>` returns the newer base a later UI PR can offer as "Update". - `native-mods.json`'s `base` stays the original release or Nightly across rebuilds. - **Same instance.** The build pins `meta.version` of the instance the mods are in, including the default **Horizon** instance. The hidden "Native mods" instance, `instance_on` and `carry_settings` are gone. - Old "Native mods" instances are ordinary Own instances with a pinned version, so they keep working with their data. - I checked the auto-update for a pinned default instance: - an update changes only `Settings::selected`, not an instance's pin; - `stale_versions` prunes only release tags (`is_game_tag`), and `nightly::after_update` only Nightlies; - so a pinned `native-*` build is neither replaced nor pruned. - **Clean build environment.** `Toolchain::command` drops `RUSTFLAGS`, `CARGO_ENCODED_RUSTFLAGS`, `RUSTDOCFLAGS`, `CARGO_ENCODED_RUSTDOCFLAGS`, `CARGO_INCREMENTAL`, `CARGO_PROFILE_*`, `CARGO_BUILD_*`, `CARGO_TARGET_*`, plus the existing rustup and wrapper variables. It also starts Cargo from the root of the disk the launcher's data is on, and the game's build passes `--manifest-path`. Why: - Cargo reads `.cargo/config.toml` from its working directory and every directory above it, whatever `CARGO_HOME` is, so from under `$HOME` it would read `~/.cargo/config.toml`. No flag turns that search off. - Overriding keys one by one doesn't work. `CARGO_BUILD_RUSTFLAGS=""` loses to `target.<triple>.rustflags`, and config `[profile]` keys can't all be listed. - Starting outside the home leaves none of the player's config files in the search. The source's own `.cargo/config.toml`, if a revision ever has one, is passed with `--config`. - **Kept builds.** `prune` keeps the 3 newest `native-*` builds that no instance plays, by `.installed` mtime. Reusing a build touches it. - **`fast` profile.** Builds use the workspace's `fast` profile (`lto = false`, `codegen-units = 16`, `incremental = true`) when the pinned source's `Cargo.toml` has one, else `release`. `native-mods.json` records which (`profile`). - `PROFILE` is part of the variant key, so release-built variants from before this PR won't match: the first build after updating the launcher compiles once. - **Low priority.** The game's `cargo build` and horizon-mixins' `cargo install` run at low priority, so the desktop doesn't freeze while they compile (`rust_toolchain::low_priority`): - Unix: nice 19 through `setpriority` in `pre_exec`, plus the idle I/O class on Linux (`ioprio_set`); - Windows: `BELOW_NORMAL_PRIORITY_CLASS`. Parallelism stays at Cargo's default, and `CARGO_BUILD_JOBS` is the one `CARGO_BUILD_*` variable that still passes through, since it changes no flag. `horizon-threads` only sets thread priorities, so it had nothing to reuse here. This adds `libc` for Unix, which was already in the lockfile. - **Fix found while measuring.** A native build's version folder had `horizon-ctl`, `horizon-server` and `horizon-prepare` without the executable bit, because a reflink clone is a new 0644 file. `install` now copies the permissions. - Docs: `docs/native-mods.md` covers rebuilds, the default instance, pruning, the clean environment, the profile, the priority and the new measurements. `docs/launcher-commands.md` is regenerated. `launcher/src/backend.rs` is **not** touched. ## Measured Linux x86_64 desktop, isolated launcher home, Nightly `6f8c7a0`, Zoom 2.0.0 + FPS Counter 2.0.0 from the registry, `nice -n 19 ionice -c 3 horizon-launcher native-build --trust-native-code` with `CARGO_BUILD_JOBS=10`, `fast` profile: | Step | Wall time | Crates compiled (`native/build.log`) | |---|---|---| | First build (downloads Rust, builds horizon-mixins, the whole game) | 4 min 29 s (game compile 3 min 6 s) | 384 | | FPS Counter off, rebuild | 56 s (compile 51 s) | 1: `horizon-client` | | FPS Counter on again | under 1 s: the kept build is played again | 0 | | Nothing changed, rebuild | 1 s | 0 | | Zoom off, rebuild | 57 s (compile 51 s) | 1: `horizon-client` | An earlier run of the same steps used the `release` profile, without nice and without a jobs cap: | Step | `release` | |---|---| | First build | 7 min 6 s (game compile 5 min 0 s) | | Each rebuild | 2 min 34 s (2 min 28 s compiling `horizon-client`) | | Re-enable, and unchanged | 0–1 s | So a rebuild recompiles only `horizon-client`, the crate the mixins touch. Nothing else is rebuilt, so there was no cause to chase. **FPS.** I compared the `fast` native build (FPS Counter on) with the Nightly's own CI `release` binary. Setup: `horizon-ctl launch --offscreen`, a new creative world with seed 12345, 40 s to load, then `bench 20`. Both ran at nice 19, alternating, two runs each. | | FPS | CPU frame time, avg | CPU p99 | GPU avg | |---|---|---|---|---| | `fast` | 111.1 / 112.9 | 0.57 / 0.68 ms | 1.42 / 1.87 ms | 0.80 / 0.84 ms | | `release` | 111.9 / 112.2 | 0.54 / 0.51 ms | 1.39 / 1.24 ms | 0.73 / 0.93 ms | FPS is vsync-bound at 120 Hz, so both are the same. CPU time per frame is about 0.1 ms (~15%) higher with `fast`. This is rough: one spot, and the fast build also draws the FPS overlay. ## Checks - `cd launcher && cargo +stable fmt --check && cargo +stable clippy --all-targets -- -D warnings && cargo +stable test`: 280 + 46 + 4 passed. - New tests: - `a_rebuild_stays_on_the_instances_horizon_until_an_update` - `the_newest_builds_no_instance_plays_are_kept` - `the_game_compiles_outside_the_players_cargo_configuration` - `the_players_compiler_settings_stay_out_of_builds` - `builds_use_the_fast_profile_where_the_source_has_it` - `builds_run_at_the_lowest_priority` (Linux: nice 19 and the idle I/O class, read back) **pr_ready** (`tools/pr_ready.py --quick --base hr/main` on cachyos-x8664, against hr/main at 7ebf7d26c, 43 s) | Check | Result | | --- | --- | | Scope | ⚠️ 8 files, +506 −179; 603 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ changes with a Cargo.toml | | Public tree | ✅ | | Python tests | ✅ 423 passed (25 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 | ✅ (1 s) | | launcher clippy | ✅ (6 s) | | launcher tests | ✅ 280 passed (11 s) | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | It is 603 lines of code, about 250 of them tests. The parts depend on each other (the base choice, the instance, the prune and the profile), so I kept them in one PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:11:21 +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#5261
No description provided.