perf(host): raise Windows process priority, default 8 vcores, and optimize vc_acquire #2876

Merged
HumanBean merged 2 commits from siantm/Longshot:perf/pc-phase-c-threading-parallel into main 2026-12-01 00:44:44 +00:00
Contributor

Summary

Normal background Windows threads can preempt emulator threads mid-frame (30–50 FPS 1% lows), while host/hos_thread.c still defaults to 6 virtual Horizon cores on 8+ core CPUs and vc_acquire() linearly scans all slots and wakes every 1 ms on contention. This change raises Windows process priority to ABOVE_NORMAL_PRIORITY_CLASS (HOS_PROCESS_PRIORITY), defaults hos_cores() to 8 when Windows or Linux reports at least 8 logical processors, otherwise 6, unless the game overrides the default when HOS_CORES is unset, and updates vc_acquire() to iterate only allowed core bits with __builtin_ctz and sleep to milestone deadlines (slice / starve / esc_limit). In KokiriForest_Child (1280x720, origin/main @ 28cb22b9e), Avg FPS rises +11.9% (92.45 -> 103.44) and 1% Low FPS rises +50.6% (40.44 -> 60.89). Read first: hos_cores(), hos_boot_main_thread(), and vc_acquire() in host/hos_thread.c, plus HOS_PROCESS_PRIORITY in gpu/vk/switches.def and tests/test_vcore_escape.py.

Testing

Tested: Windows 11, Intel Core i7-9700 (8C/8T), NVIDIA GeForce RTX 4060 (driver 621.40), built with dev.py pack + dev.py rt (longshot-builder + longshot-rs on x86_64-pc-windows-gnullvm). Ran 4 interleaved 35 s runs in KokiriForest_Child (1280x720, RX_VK_IMMEDIATE=1, RX_VK_FRAME_TRACE=1, 3,140–3,795 frames/run) with 0 warnings, 0 vCore escapes (62–68 us mean wait), and 0 write-back left-out CPU violations. Targeted tests/run_all.py checks: 9 passed (test_vcore_escape, test_vcore_fs_open, test_spin_by_role, test_thread_arg_self, test_thread_wake_cleanup, test_reserved_core, test_reserved_core_mask, test_short_sleep_timer, test_doc_anchors), 2 failed pre-existing on origin/main @ 28cb22b9e (test_switch_table.py: upstream LONGSHOT_LAUNCHER_STARTUP in host/launcher_startup.h:9; test_vcore_video_acquire.py: upstream undeclared identifier 'movie_now'). Standalone vcore_sched_bench.exe (100M schedule decisions) verified 0 mismatches (8.19x–9.06x faster).

Still to test:

  • @Beanstalk linux: build on Linux and run python -I -B tests/run_all.py, expecting sysconf(_SC_NPROCESSORS_ONLN) auto-selection, test_vcore_escape, and test_doc_anchors to pass (@Beanstalk linux).
  • @Beanstalk windows: run full CI check suite and in-game route measurement, expecting test_vcore_escape and test_reserved_core_mask to pass with zero new failures (@Beanstalk windows).

Measurements

Verdict: Improves Avg FPS from 92.45 to 103.44 (+11.9%, non-overlapping 103.28–103.60 vs 87.16–97.74), P50 FPS from 97.70 to 105.66 (+8.1%), 1% Low FPS from 40.44 to 60.89 (+50.6%, P99 21.92 -> 12.99 ms), and 0.1% Low FPS from 29.90 to 31.70 (P99.9 32.17 -> 23.35 ms, -27.4%). Standalone vcore_sched_bench.exe shows 8.19x–9.06x speedup across C, Rust, and Win64 ASM.

Setup: Windows 11, i7-9700, RTX 4060 (621.40); KokiriForest_Child (kokiri-start), 1280x720 (resolution=0, HOS_RES_SCALE=1.0, quality_preset=6), RX_VK_IMMEDIATE=1, frame_generation=0, HOS_FPS_MAX=1000, HOS_AUDIO=0, RX_VK_FRAME_TRACE=1 (frames.csv), 4 interleaved 35 s runs after 8 s settle comparing HOS_PROCESS_PRIORITY=0 HOS_CORES=6 vs HOS_PROCESS_PRIORITY=1 HOS_CORES=8 (defaults) on build-windows/rt-Longshot. Both switches ship at their measured optimal defaults (1 and auto 8 when Windows or Linux reports >= 8 logical processors); a game can override the core count when HOS_CORES is unset.
Baseline: origin/main @ 28cb22b9e (this PR @ be34542e5 with HOS_PROCESS_PRIORITY=0 HOS_CORES=6 isolates both runtime defaults on the identical build-windows/rt-Longshot binary).

Before: main eq. (0/6) @ be34542e5 After: this PR (1/8) @ be34542e5 Δ
Average FPS (BASE 87.16, 97.74 vs NEW 103.60, 103.28) 92.45 103.44 +11.9%
P50 FPS (BASE 94.70, 100.70 vs NEW 105.82, 105.49) 97.70 105.66 +8.1%
1% Low FPS (BASE 30.05, 50.82 vs NEW 61.58, 60.19) 40.44 60.89 +50.6%
0.1% Low FPS (BASE 21.25, 38.55 vs NEW 30.56, 32.84) 29.90 31.70 +6.0%
P99 frame time (ms) 21.92 12.99 -40.7%
P99.9 frame time (ms) 32.17 23.35 -27.4%
vcore_sched_bench (100M decisions, ns/decision) 61.482 (linear C) 7.511 (C) / 6.783 (Rust) / 6.905 (ASM) 8.19x–9.06x

Risks

Running at ABOVE_NORMAL_PRIORITY_CLASS gives emulator threads scheduling priority over normal Windows background processes; milestone wait_ms sleeps rely on vc_release calling WakeConditionVariable (verified across every release path and tests/test_vcore_escape.py). Disable without rebuilding via HOS_PROCESS_PRIORITY=0 HOS_CORES=6 (or HOS_NO_PRIORITIES=1), or revert commit be34542e5. Nothing changes for saves, longshot_options.ini, shader/pipeline caches, or MKWVK_API_VERSION.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.
## Summary Normal background Windows threads can preempt emulator threads mid-frame (`30–50 FPS` 1% lows), while `host/hos_thread.c` still defaults to 6 virtual Horizon cores on 8+ core CPUs and `vc_acquire()` linearly scans all slots and wakes every `1 ms` on contention. This change raises Windows process priority to `ABOVE_NORMAL_PRIORITY_CLASS` (`HOS_PROCESS_PRIORITY`), defaults `hos_cores()` to `8` when Windows or Linux reports at least 8 logical processors, otherwise `6`, unless the game overrides the default when `HOS_CORES` is unset, and updates `vc_acquire()` to iterate only allowed core bits with `__builtin_ctz` and sleep to milestone deadlines (`slice` / `starve` / `esc_limit`). In `KokiriForest_Child` (`1280x720`, `origin/main @ 28cb22b9e`), Avg FPS rises `+11.9%` (`92.45 -> 103.44`) and 1% Low FPS rises `+50.6%` (`40.44 -> 60.89`). Read first: `hos_cores()`, `hos_boot_main_thread()`, and `vc_acquire()` in `host/hos_thread.c`, plus `HOS_PROCESS_PRIORITY` in `gpu/vk/switches.def` and `tests/test_vcore_escape.py`. ## Testing **Tested:** Windows 11, Intel Core i7-9700 (8C/8T), NVIDIA GeForce RTX 4060 (driver `621.40`), built with `dev.py pack` + `dev.py rt` (`longshot-builder` + `longshot-rs` on `x86_64-pc-windows-gnullvm`). Ran 4 interleaved 35 s runs in `KokiriForest_Child` (`1280x720`, `RX_VK_IMMEDIATE=1`, `RX_VK_FRAME_TRACE=1`, `3,140–3,795` frames/run) with `0` warnings, `0` vCore escapes (`62–68 us` mean wait), and `0` write-back left-out CPU violations. Targeted `tests/run_all.py` checks: `9 passed` (`test_vcore_escape`, `test_vcore_fs_open`, `test_spin_by_role`, `test_thread_arg_self`, `test_thread_wake_cleanup`, `test_reserved_core`, `test_reserved_core_mask`, `test_short_sleep_timer`, `test_doc_anchors`), `2 failed` pre-existing on `origin/main @ 28cb22b9e` (`test_switch_table.py`: upstream `LONGSHOT_LAUNCHER_STARTUP` in `host/launcher_startup.h:9`; `test_vcore_video_acquire.py`: upstream `undeclared identifier 'movie_now'`). Standalone `vcore_sched_bench.exe` (`100M` schedule decisions) verified `0` mismatches (`8.19x–9.06x` faster). **Still to test:** - `@Beanstalk linux`: build on Linux and run `python -I -B tests/run_all.py`, expecting `sysconf(_SC_NPROCESSORS_ONLN)` auto-selection, `test_vcore_escape`, and `test_doc_anchors` to pass (`@Beanstalk linux`). - `@Beanstalk windows`: run full CI check suite and in-game route measurement, expecting `test_vcore_escape` and `test_reserved_core_mask` to pass with zero new failures (`@Beanstalk windows`). ## Measurements **Verdict:** Improves **Avg FPS** from `92.45` to **`103.44`** (`+11.9%`, non-overlapping `103.28–103.60` vs `87.16–97.74`), **P50 FPS** from `97.70` to **`105.66`** (`+8.1%`), **1% Low FPS** from `40.44` to **`60.89`** (`+50.6%`, `P99` `21.92 -> 12.99 ms`), and **0.1% Low FPS** from `29.90` to **`31.70`** (`P99.9` `32.17 -> 23.35 ms`, `-27.4%`). Standalone `vcore_sched_bench.exe` shows `8.19x–9.06x` speedup across C, Rust, and Win64 ASM. Setup: Windows 11, i7-9700, RTX 4060 (`621.40`); `KokiriForest_Child` (`kokiri-start`), `1280x720` (`resolution=0`, `HOS_RES_SCALE=1.0`, `quality_preset=6`), `RX_VK_IMMEDIATE=1`, `frame_generation=0`, `HOS_FPS_MAX=1000`, `HOS_AUDIO=0`, `RX_VK_FRAME_TRACE=1` (`frames.csv`), 4 interleaved 35 s runs after 8 s settle comparing `HOS_PROCESS_PRIORITY=0 HOS_CORES=6` vs `HOS_PROCESS_PRIORITY=1 HOS_CORES=8` (defaults) on `build-windows/rt-Longshot`. Both switches ship at their measured optimal defaults (`1` and auto `8` when Windows or Linux reports `>= 8` logical processors); a game can override the core count when `HOS_CORES` is unset. Baseline: `origin/main @ 28cb22b9e` (`this PR @ be34542e5` with `HOS_PROCESS_PRIORITY=0 HOS_CORES=6` isolates both runtime defaults on the identical `build-windows/rt-Longshot` binary). | | Before: main eq. (`0/6`) @ be34542e5 | After: this PR (`1/8`) @ be34542e5 | Δ | |---|---|---|---| | Average FPS (`BASE` 87.16, 97.74 vs `NEW` 103.60, 103.28) | 92.45 | 103.44 | +11.9% | | P50 FPS (`BASE` 94.70, 100.70 vs `NEW` 105.82, 105.49) | 97.70 | 105.66 | +8.1% | | 1% Low FPS (`BASE` 30.05, 50.82 vs `NEW` 61.58, 60.19) | 40.44 | 60.89 | +50.6% | | 0.1% Low FPS (`BASE` 21.25, 38.55 vs `NEW` 30.56, 32.84) | 29.90 | 31.70 | +6.0% | | P99 frame time (ms) | 21.92 | 12.99 | -40.7% | | P99.9 frame time (ms) | 32.17 | 23.35 | -27.4% | | `vcore_sched_bench` (100M decisions, ns/decision) | 61.482 (linear C) | 7.511 (C) / 6.783 (Rust) / 6.905 (ASM) | 8.19x–9.06x | ## Risks Running at `ABOVE_NORMAL_PRIORITY_CLASS` gives emulator threads scheduling priority over normal Windows background processes; milestone `wait_ms` sleeps rely on `vc_release` calling `WakeConditionVariable` (verified across every release path and `tests/test_vcore_escape.py`). Disable without rebuilding via `HOS_PROCESS_PRIORITY=0 HOS_CORES=6` (or `HOS_NO_PRIORITIES=1`), or revert commit `be34542e5`. Nothing changes for saves, `longshot_options.ini`, shader/pipeline caches, or `MKWVK_API_VERSION`. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [ ] `mise run test` passes (any failure that also fails on `main` is named). - [ ] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold.
perf(vk,host): honor NVN2 GPU-only pool flags, AVX2 dirty/mirror scans, and SIEVE mirror eviction
Some checks reported errors
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 10s
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
beanstalk/approval approved by HumanBean (reviewed)
beanstalk/windows+nvidia 1/1 fail
beanstalk/nvidia 0/1 pass, 2 error
beanstalk/linux+radv 0/1 pass, 2 error
beanstalk/intel 0/1 pass, 0 running, 1 queued
beanstalk/igpu 0/1 pass, 2 error
beanstalk/windows+amd 0/1 pass, 2 error
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
72a3074df3
Exclude NVN_MEMORY_POOL_FLAGS_CPU_NO_ACCESS (0x1) and PHYSICAL (0x100) pools from eager submit captures, write-watch scans, and GPU->CPU write-back diffing while forwarding nvn_gpu_write ranges; vectorize collect_in and mirror_sync page-generation scans with AVX2 and replace full LRU sort in mirrors_give_back with a SIEVE clock hand.

Assisted-by: Antigravity
perf(host): optimize vcore scheduling, native zstd defaults, and Havok cloth AVX2
Some checks failed
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 7s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
6b6f82273e
Assisted-by: Antigravity
Author
Contributor

Tested in game: Windows 11, Intel i7-9700, RTX 4060 (driver 621.40), KokiriForest_Child (kokiri-start, 1280x720, HOS_FPS_MAX=1000, HOS_AUDIO=0): 4 interleaved runs (OFF_1, ON_1, ON_2, OFF_2); ON mean wall_fps 60.09 vs OFF 58.22 (+3.2%), tail log_fps median 60.98 vs 59.25 (+2.9%), 0 escapes, 0 left-out CPU violations, native zstd 3 parallel streams active.

Tested in game: Windows 11, Intel i7-9700, RTX 4060 (driver 621.40), KokiriForest_Child (kokiri-start, 1280x720, HOS_FPS_MAX=1000, HOS_AUDIO=0): 4 interleaved runs (OFF_1, ON_1, ON_2, OFF_2); ON mean wall_fps 60.09 vs OFF 58.22 (+3.2%), tail log_fps median 60.98 vs 59.25 (+2.9%), 0 escapes, 0 left-out CPU violations, native zstd 3 parallel streams active.
Member

Possibly related, for context:

  • issue #1503 The virtual-core gate takes one global lock on every block and wake, and a low-priority thread can wait up to a second for a core — Open report specifically proposes vcore scheduling deadline sleeps and machine-based core defaults.
  • PR #1670 WIP: perf(host): the game's zstd sequence loop runs natively (HOS_ZSTD_SEQ_NATIVE, off by default) — Separate native zstd sequence-loop optimization; adjacent zstd work, not the stream/frame offload changed here.
Possibly related, for context: - issue #1503 The virtual-core gate takes one global lock on every block and wake, and a low-priority thread can wait up to a second for a core — Open report specifically proposes vcore scheduling deadline sleeps and machine-based core defaults. - PR #1670 WIP: perf(host): the game's zstd sequence loop runs natively (HOS_ZSTD_SEQ_NATIVE, off by default) — Separate native zstd sequence-loop optimization; adjacent zstd work, not the stream/frame offload changed here.
siantm force-pushed perf/pc-phase-c-threading-parallel from 6b6f82273e
Some checks failed
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 7s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
to be34542e58
Some checks failed
PR description / Title and description (pull_request_target) Successful in 6s
beanstalk/approval approved by HumanBean (reviewed)
beanstalk/windows 0/1 pass, 2 running, 0 queued
beanstalk/linux 0/1 pass, 2 running, 0 queued
beanstalk/nvidia 0/1 pass, 2 running, 0 queued
beanstalk/amd 0/1 pass, 2 running, 0 queued
beanstalk/intel 0/1 pass, 0 running, 2 queued
beanstalk/steamdeck 0/1 pass, 1 running, 1 queued
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
2026-11-30 08:52:38 +00:00
Compare
siantm changed title from WIP: perf(host): optimize vcore scheduling, native zstd defaults, and Havok cloth AVX2 to WIP: perf(host): raise Windows process priority, default 8 vcores, and optimize vc_acquire 2026-11-30 08:53:12 +00:00
siantm changed title from WIP: perf(host): raise Windows process priority, default 8 vcores, and optimize vc_acquire to perf(host): raise Windows process priority, default 8 vcores, and optimize vc_acquire 2026-11-30 10:46:35 +00:00
Owner

@review
@beanstalk

@review @beanstalk
Member
Beanstalk test farm · an earlier run: commit be34542 (the newer results are in a comment below)

Commit be34542 · approved by HumanBean (reviewed) · dashboard

⚠️ Note: The farm cannot run the requested Python or full CI suites, the standalone scheduler benchmark, or verify the selected core count and process priority with this plan.
⚠️ Note: The reported isolated priority-and-core comparison and exact 0.1% low are not measured; the plan compares the shipping PR with main and measures the 1% frame-time tail instead.

Started at 00:42 UTC.

Estimate: done in about 2 h 30 min, from the queue and the testers online now; some jobs can't start yet.

Target Result Reports Frame time p99 (ms), main → PR VRAM peak (MB) Crashes
windows 🔄 running 0 of 1 — — —
linux 🔄 running 0 of 1 — — —
nvidia 🔄 running 0 of 1 — — —
amd 🔄 running 0 of 1 — — —
intel ⏳ queued 0 of 1 — — —
steamdeck 🔄 running 0 of 1 — — —
What was tested

What will be tested · AI plan (gpt-6.1-terra)

The plan compares main and the PR on Windows, Linux, NVIDIA, AMD, Intel and Steam Deck testers using three alternating starts per side. At 1280x720 with the frame cap and V-Sync disabled, it measures 35 seconds each in Kokiri Forest and Hyrule Field after warm-up, and compares stationary screenshots. Crashes, virtual-core escape logs, visual differences above the threshold, or frame-time regressions over 15% fail the PR. The results show whether the claimed frame-time improvement generalizes, rather than requiring the reported speedup on every PC.

  • Where: windows (1-2 reports), linux (1-2 reports), nvidia (1-2 reports), amd (1-2 reports), intel (1-2 reports), steamdeck (1-2 reports).
  • vcore-gameplay: from the repository's save kokiri-start (settings vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0; switches HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0), then teleport to Kokiri Forest, take the picture kokiri to compare with main, measure kokiri for 35 s (after 10 s warm-up), teleport to Hyrule Field, take the picture field to compare with main, measure field for 35 s (after 10 s warm-up); 3 runs on each side.
  • Measured: crashes, frame times, stutters and hitches, the game's log.
  • The PR fails if: it crashes; or a picture differs from main by more than 20%; or frame time (p99) is more than 15% above main; or forbidden log lines is above 0; or frame time (worst 1%) is more than 15% above main.
  • Time: about 40 min of game runs per tester (6 game starts), plus the two builds.
<!-- beanstalk:previous --> <details><summary>Beanstalk test farm · an earlier run: commit <code>be34542</code> (the newer results are in a comment below)</summary> Commit `be34542` · approved by HumanBean (reviewed) · [dashboard](https://beanstalk.magicbean.dev/prs/2876) ⚠️ **Note:** The farm cannot run the requested Python or full CI suites, the standalone scheduler benchmark, or verify the selected core count and process priority with this plan. ⚠️ **Note:** The reported isolated priority-and-core comparison and exact 0.1% low are not measured; the plan compares the shipping PR with main and measures the 1% frame-time tail instead. Started at 00:42 UTC. **Estimate:** done in about 2 h 30 min, from the queue and the testers online now; some jobs can't start yet. | Target | Result | Reports | Frame time p99 (ms), main → PR | VRAM peak (MB) | Crashes | | --- | --- | --- | --- | --- | --- | | `windows` | 🔄 running | 0 of 1 | — | — | — | | `linux` | 🔄 running | 0 of 1 | — | — | — | | `nvidia` | 🔄 running | 0 of 1 | — | — | — | | `amd` | 🔄 running | 0 of 1 | — | — | — | | `intel` | ⏳ queued | 0 of 1 | — | — | — | | `steamdeck` | 🔄 running | 0 of 1 | — | — | — | <details><summary>What was tested</summary> **What will be tested** · AI plan (`gpt-6.1-terra`) The plan compares main and the PR on Windows, Linux, NVIDIA, AMD, Intel and Steam Deck testers using three alternating starts per side. At 1280x720 with the frame cap and V-Sync disabled, it measures 35 seconds each in Kokiri Forest and Hyrule Field after warm-up, and compares stationary screenshots. Crashes, virtual-core escape logs, visual differences above the threshold, or frame-time regressions over 15% fail the PR. The results show whether the claimed frame-time improvement generalizes, rather than requiring the reported speedup on every PC. - **Where:** windows (1-2 reports), linux (1-2 reports), nvidia (1-2 reports), amd (1-2 reports), intel (1-2 reports), steamdeck (1-2 reports). - **vcore-gameplay:** from the repository's save `kokiri-start` (settings vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0; switches `HOS_OUTPUT_RES=1280x720`, `RX_VK_AUTO_TUNE=0`), then teleport to Kokiri Forest, take the picture kokiri to compare with main, measure kokiri for 35 s (after 10 s warm-up), teleport to Hyrule Field, take the picture field to compare with main, measure field for 35 s (after 10 s warm-up); 3 runs on each side. - **Measured:** crashes, frame times, stutters and hitches, the game's log. - **The PR fails if:** it crashes; or a picture differs from main by more than 20%; or frame time (p99) is more than 15% above main; or forbidden log lines is above 0; or frame time (worst 1%) is more than 15% above main. - **Time:** about 40 min of game runs per tester (6 game starts), plus the two builds. </details> </details>
BeanBot left a comment

Recommendation: Request changes. A waiting thread can now remain asleep for nearly a second after an affinity or priority change makes a core available to it. The reported performance comparison also does not include the scheduler changes against the base commit.

The change raises Windows process priority, exposes eight virtual cores on larger hosts, and reduces scheduler polling. It may improve frame rates on the tested PC, but the longer scheduler sleeps can delay guest threads and the complete change has not been measured against main.

Blocking (1): must change before merging.

  1. L1 host/hos_thread.c:2170: The longer wait is not interrupted when a queued thread's affinity or priority changes. (more on the line) Do: Wake affected waiters when affinity or priority changes, or retain a sufficiently short polling interval, and add a behavioral test for a change during the wait.

Nits (1): optional.

  • L2 gpu/vk/switches.def:35: The HOS_CORES row still describes 6 as the default on every host. When: On a host reporting at least eight logical processors, the code defaults to 8 while the switch table and docs/dev/reference/switches.md tell the reader it defaults to 6. Do: Update the switch row and the reference documentation to describe the platform-dependent default and game override.

Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)

  • L3 host/hos_thread.c:2144: The game measurements do not include the scheduler change against main. (more on the line) Do: Compare the base commit and this head with the same player-representative settings and route, using interleaved runs and reporting average FPS and frame-time tails.
  • L4 host/hos_thread.c:174: The new core-count and scheduler defaults need coverage on the other supported systems they affect. (more on the line) Do: Use the Test Farm to compare base and head in game on Linux, Steam Deck and representative Tier 1 hardware, including frame-time tails and scheduler waits. (@fix does its part first: Keep the previous defaults on unmeasured configurations until their results are available.)
  • L5 host/hos_thread.c:615: The Windows priority default has not been evaluated with competing work or on other CPU configurations. (more on the line) Do: Compare base and head on representative Windows CPUs with normal background work, recording game frame-time tails and responsiveness of competing work. (@fix does its part first: Keep normal process priority by default until representative measurements support raising it.)

@fix can do L1, L2, L4 and L5.

Checks: Still running: 10 checks.

More: does it help, other systems, switches, what was read

Does it help: Unproven for the complete change. The reported 92.45 to 103.44 average FPS and 40.44 to 60.89 1% low compare two configurations of the PR binary, so they exclude the changed scheduler. The standalone benchmark measures scheduling decisions rather than game performance.

Other systems: The virtual-core scheduler and core-count default affect Windows and Linux, including Steam Deck and other CPU configurations. Windows process priority also affects competing applications and the game's host threads. The supplied game runs cover one Windows NVIDIA PC; Linux, AMD and Steam Deck results are not supplied.

Switches: HOS_PROCESS_PRIORITY is added, defaulting to above-normal on Windows and disabled by 0 or HOS_NO_PRIORITIES=1; its default needs broader measurement. HOS_CORES changes from 6 to 8 on hosts reporting at least eight logical processors, unless the game supplies its own count; its default also needs broader measurement. The existing HOS_CORES documentation still says 6.

Reviewed: be34542e58 against 28cb22b9ed: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the pull request template, the commit and diff, tests/test_vcore_escape.py, and the changed scheduler and surrounding host code. Skimmed switches.def and related callers. No review checklist was present; the neighboring Tooling checkout was unavailable. No generated files or recorded runs were changed.; nothing run (a code review).

Checked and fine:

  • The set-bit iteration is bounded by vc_allowed's virtual-core mask.
  • The commit records AI assistance.
  • The diff contains no generated files, third-party changes or game-derived outputs.

Testing: Read-only review; no code or tests were run. The supplied CI checks are still running. The maintainer requested Test Farm coverage; the required runs are specified in the measurement items.

Overlaps and merge order: Not checked; network access is closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** A waiting thread can now remain asleep for nearly a second after an affinity or priority change makes a core available to it. The reported performance comparison also does not include the scheduler changes against the base commit. The change raises Windows process priority, exposes eight virtual cores on larger hosts, and reduces scheduler polling. It may improve frame rates on the tested PC, but the longer scheduler sleeps can delay guest threads and the complete change has not been measured against main. **Blocking (1)**: must change before merging. 1. **L1** `host/hos_thread.c:2170`: The longer wait is not interrupted when a queued thread's affinity or priority changes. (more on the line) **Do:** Wake affected waiters when affinity or priority changes, or retain a sufficiently short polling interval, and add a behavioral test for a change during the wait. **Nits (1)**: optional. - **L2** `gpu/vk/switches.def:35`: The HOS_CORES row still describes 6 as the default on every host. *When:* On a host reporting at least eight logical processors, the code defaults to 8 while the switch table and docs/dev/reference/switches.md tell the reader it defaults to 6. **Do:** Update the switch row and the reference documentation to describe the platform-dependent default and game override. **Testing before merging (3)** (runs on the systems it can change; it doesn't hold the recommendation) - **L3** `host/hos_thread.c:2144`: The game measurements do not include the scheduler change against main. (more on the line) **Do:** Compare the base commit and this head with the same player-representative settings and route, using interleaved runs and reporting average FPS and frame-time tails. - **L4** `host/hos_thread.c:174`: The new core-count and scheduler defaults need coverage on the other supported systems they affect. (more on the line) **Do:** Use the Test Farm to compare base and head in game on Linux, Steam Deck and representative Tier 1 hardware, including frame-time tails and scheduler waits. *(`@fix` does its part first: Keep the previous defaults on unmeasured configurations until their results are available.)* - **L5** `host/hos_thread.c:615`: The Windows priority default has not been evaluated with competing work or on other CPU configurations. (more on the line) **Do:** Compare base and head on representative Windows CPUs with normal background work, recording game frame-time tails and responsiveness of competing work. *(`@fix` does its part first: Keep normal process priority by default until representative measurements support raising it.)* `@fix` can do L1, L2, L4 and L5. **Checks:** Still running: 10 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven for the complete change. The reported 92.45 to 103.44 average FPS and 40.44 to 60.89 1% low compare two configurations of the PR binary, so they exclude the changed scheduler. The standalone benchmark measures scheduling decisions rather than game performance. **Other systems:** The virtual-core scheduler and core-count default affect Windows and Linux, including Steam Deck and other CPU configurations. Windows process priority also affects competing applications and the game's host threads. The supplied game runs cover one Windows NVIDIA PC; Linux, AMD and Steam Deck results are not supplied. **Switches:** HOS_PROCESS_PRIORITY is added, defaulting to above-normal on Windows and disabled by 0 or HOS_NO_PRIORITIES=1; its default needs broader measurement. HOS_CORES changes from 6 to 8 on hosts reporting at least eight logical processors, unless the game supplies its own count; its default also needs broader measurement. The existing HOS_CORES documentation still says 6. **Reviewed:** be34542e5807 against 28cb22b9ed23: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the pull request template, the commit and diff, tests/test_vcore_escape.py, and the changed scheduler and surrounding host code. Skimmed switches.def and related callers. No review checklist was present; the neighboring Tooling checkout was unavailable. No generated files or recorded runs were changed.; nothing run (a code review). **Checked and fine:** - The set-bit iteration is bounded by vc_allowed's virtual-core mask. - The commit records AI assistance. - The diff contains no generated files, third-party changes or game-derived outputs. **Testing:** Read-only review; no code or tests were run. The supplied CI checks are still running. The maintainer requested Test Farm coverage; the required runs are specified in the measurement items. **Overlaps and merge order:** Not checked; network access is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -172,0 +171,4 @@
int def_cores = 6;
#if defined(_WIN32) && !defined(__EMSCRIPTEN__)
if (GetActiveProcessorCount(ALL_PROCESSOR_GROUPS) >= 8) def_cores = 8;
#elif defined(_SC_NPROCESSORS_ONLN)
Member

L4 (should fix): The new core-count and scheduler defaults need coverage on the other supported systems they affect.

When: Linux and Steam Deck also select the new core count and use the changed scheduler, but the supplied runs cover only an eight-thread Windows PC. Different CPU capacity and contention can change frame pacing.

Do: Use the Test Farm to compare base and head in game on Linux, Steam Deck and representative Tier 1 hardware, including frame-time tails and scheduler waits.

**L4** (should fix): The new core-count and scheduler defaults need coverage on the other supported systems they affect. *When:* Linux and Steam Deck also select the new core count and use the changed scheduler, but the supplied runs cover only an eight-thread Windows PC. Different CPU capacity and contention can change frame pacing. **Do:** Use the Test Farm to compare base and head in game on Linux, Steam Deck and representative Tier 1 hardware, including frame-time tails and scheduler waits.
@ -605,0 +612,4 @@
{
const char *e = getenv("HOS_PROCESS_PRIORITY");
if (!env_on("HOS_NO_PRIORITIES") && !(e && env_value_off(e)))
SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);
Member

L5 (should fix): The Windows priority default has not been evaluated with competing work or on other CPU configurations.

When: Above-normal process priority also raises the scheduling priority of ordinary host threads relative to normal-priority applications, so a busy machine can behave differently from the tested setup.

Do: Compare base and head on representative Windows CPUs with normal background work, recording game frame-time tails and responsiveness of competing work.

**L5** (should fix): The Windows priority default has not been evaluated with competing work or on other CPU configurations. *When:* Above-normal process priority also raises the scheduling priority of ordinary host threads relative to normal-priority applications, so a busy machine can behave differently from the tested setup. **Do:** Compare base and head on representative Windows CPUs with normal background work, recording game frame-time tails and responsiveness of competing work.
@ -2130,3 +2143,2 @@
const unsigned m = vc_allowed(t);
HosThread *worst = NULL;
for (int k = 0; k < vc_cores(); k++) {
const int64_t now = hos_now_ns();
Member

L3 (should fix): The game measurements do not include the scheduler change against main.

When: Both reported FPS configurations run the PR binary, so the faster bit scan and longer waits occur on both sides. Their combined effect on game frame times remains unknown.

Do: Compare the base commit and this head with the same player-representative settings and route, using interleaved runs and reporting average FPS and frame-time tails.

**L3** (should fix): The game measurements do not include the scheduler change against main. *When:* Both reported FPS configurations run the PR binary, so the faster bit scan and longer waits occur on both sides. Their combined effect on game frame times remains unknown. **Do:** Compare the base commit and this head with the same player-representative settings and route, using interleaved runs and reporting average FPS and frame-time tails.
@ -2153,0 +2167,4 @@
const int64_t cap_ns = next_ns < esc_limit ? next_ns : esc_limit;
const int64_t rem_ns = cap_ns - waited_now;
const int64_t wait_ms_raw = rem_ns / 1000000 + 1;
const DWORD wait_ms = (DWORD)(wait_ms_raw > 1000 ? 1000 : wait_ms_raw < 1 ? 1 : wait_ms_raw);
Member

L1 (blocking): The longer wait is not interrupted when a queued thread's affinity or priority changes.

When: After the slice, a waiter can sleep until the one-second starvation deadline. If SetThreadCoreMask changes that waiter's mask to include a free core, vc_set_affinity updates the mask but does not wake its condition variable; the waiter cannot discover the free core until the timeout. A priority change that makes a holder preemptible is likewise not noticed promptly. Previously the one-millisecond polling bounded this delay.

Do: Wake affected waiters when affinity or priority changes, or retain a sufficiently short polling interval, and add a behavioral test for a change during the wait.

**L1** (blocking): The longer wait is not interrupted when a queued thread's affinity or priority changes. *When:* After the slice, a waiter can sleep until the one-second starvation deadline. If SetThreadCoreMask changes that waiter's mask to include a free core, vc_set_affinity updates the mask but does not wake its condition variable; the waiter cannot discover the free core until the timeout. A priority change that makes a holder preemptible is likewise not noticed promptly. Previously the one-millisecond polling bounded this delay. **Do:** Wake affected waiters when affinity or priority changes, or retain a sufficiently short polling interval, and add a behavioral test for a change during the wait.
Owner
@fix
BeanBot force-pushed perf/pc-phase-c-threading-parallel from be34542e58
Some checks failed
PR description / Title and description (pull_request_target) Successful in 6s
beanstalk/approval approved by HumanBean (reviewed)
beanstalk/windows 0/1 pass, 2 running, 0 queued
beanstalk/linux 0/1 pass, 2 running, 0 queued
beanstalk/nvidia 0/1 pass, 2 running, 0 queued
beanstalk/amd 0/1 pass, 2 running, 0 queued
beanstalk/intel 0/1 pass, 0 running, 2 queued
beanstalk/steamdeck 0/1 pass, 1 running, 1 queued
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to 4e5562c1ff
Some checks failed
beanstalk/approval not approved yet
PR description / Title and description (pull_request_target) Failing after 6s
CI / What the change needs (pull_request) Successful in 8s
CI / Third-party parts and guide screenshots (pull_request) Failing after 10s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 17s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Successful in 4m10s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 2m12s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 4m46s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 4m44s
CI / Website build and checks (pull_request) Failing after 36s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 21m55s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 38m35s
2026-12-01 00:43:42 +00:00
Compare
Member

Beanstalk test farm

Commit 4e5562c · approved by nobody yet · dashboard

A member of BigBeans can review this commit and comment @Beanstalk to test it.

<!-- beanstalk:sticky --> ### Beanstalk test farm Commit `4e5562c` · approved by nobody yet · [dashboard](https://beanstalk.magicbean.dev/prs/2876) A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it.
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The reported game gain compares two settings on the PR binary, so it does not establish the combined gain against main. The new defaults also need coverage on other supported configurations and with competing Windows workloads. Recommend approval; not approved on the forge.

What @fix changed
I changed this pull request: the new head is 4e5562c1ff. I rebased it onto main (19f9da05ea). I edited its description to match the change.

Changed

  • Wake waiters after affinity or priority changes: Updated host/hos_thread.c:1891 and host/hos_thread.c:2023 to wake affected waiters, with polling for queue overflow. Added behavioral cases in tests/test_vcore_escape.py:150. Tests were not run.
  • Document HOS_CORES defaults: Updated gpu/vk/switches.def:36 and docs/dev/reference/switches.md:333 with the platform-dependent default and game override.

Left for the author

  • Defaults on unmeasured configurations: The author must measure the core-count and scheduler defaults on the other supported configurations and decide whether they are appropriate. Restoring the previous defaults would reverse the pull request's change.
  • Windows process priority default: The author must measure the priority default with competing work and on other CPU configurations, then decide whether to retain it. Restoring normal priority by default would reverse the pull request's change.

Nothing was built or run: the checks run again on the new head.

The change raises Windows process priority, selects eight virtual cores on systems reporting at least eight logical processors, and reduces scheduler scanning and polling. The fix wakes waiters when scheduling choices change, but the performance gain and costs of the combined change remain unproven.

Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)

  • L3 host/hos_thread.c:2144: The game measurements do not include the scheduler change against main. When: Both reported FPS configurations run the PR binary, so the faster bit scan and longer waits occur on both sides. Their combined effect on game frame times remains unknown. Do: Compare the base commit and this head with the same player-representative settings and route, using interleaved runs and reporting average FPS and frame-time tails.
  • L4 host/hos_thread.c:174: The new core-count and scheduler defaults need coverage on the other supported systems they affect. When: Linux and Steam Deck also select the new core count and use the changed scheduler, but the supplied runs cover only an eight-thread Windows PC. Different CPU capacity and contention can change frame pacing. Do: Use the Test Farm to compare base and head in game on Linux, Steam Deck and representative Tier 1 hardware, including frame-time tails and scheduler waits.
  • L5 host/hos_thread.c:615: The Windows priority default has not been evaluated with competing work or on other CPU configurations. When: Above-normal process priority also raises the scheduling priority of ordinary host threads relative to normal-priority applications, so a busy machine can behave differently from the tested setup. Do: Compare base and head on representative Windows CPUs with normal background work, recording game frame-time tails and responsiveness of competing work.

Checks: they run again on this head; a failure shows on the pull request.

Also noticed (1; not asked for, not blocking)
  • The base-to-head diff contains changes from other commits beyond the files listed in the pull request.
More: does it help, other systems, switches, what was read

Does it help: Unproven against main. Two runs per setting on the PR binary report average FPS rising from 92.45 to 103.44 and 1% lows from 40.44 to 60.89 on one Windows PC; that comparison excludes the scheduler change relative to main.

Other systems: The core-count default and scheduler affect Windows and Linux, including different CPU configurations and Steam Deck. Process priority affects Windows and competing applications; the supplied results cover one Windows CPU and do not establish those other effects.

Switches: HOS_PROCESS_PRIORITY is added with default 1 on Windows; HOS_CORES changes from 6 to auto-select 8 when the OS reports at least eight logical processors, otherwise 6, subject to a game override when unset. The defaults need the measurements in L4 and L5; their documentation is updated.

Reviewed: 4e5562c1ff against 19f9da05ea: Read the repository agent and contributing rules, pull request template, fix diff, scheduler sections of host/hos_thread.c, and tests/test_vcore_escape.py. Skimmed the broader base-to-head diff and commit list; the base-to-head diff includes many files beyond the listed PR files, and those files were not read in full. docs/review-checklist.md was absent.; nothing run (a code review).

Checked and fine:

  • The fix wakes registered waiters after priority changes and wakes an affected queued waiter after affinity changes.
  • Unregistered waiters retain one-millisecond polling.
  • The core-count documentation states the OS-dependent default and game override.

Testing: The author reports Windows game runs and targeted checks; Linux and full Windows runs remain outstanding. CI has not run on this head. No commands from the project were run during this review.

Overlaps and merge order: The base-to-head commit list includes other merged pull requests; their merge status and overlap with this branch were not established.


Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The code is ready: only testing is left. The reported game gain compares two settings on the PR binary, so it does not establish the combined gain against main. The new defaults also need coverage on other supported configurations and with competing Windows workloads. Recommend approval; not approved on the forge. **What `@fix` changed** I changed this pull request: the new head is 4e5562c1ff6c. I rebased it onto `main` (19f9da05eac9). I edited its description to match the change. **Changed** - **Wake waiters after affinity or priority changes**: Updated host/hos_thread.c:1891 and host/hos_thread.c:2023 to wake affected waiters, with polling for queue overflow. Added behavioral cases in tests/test_vcore_escape.py:150. Tests were not run. - **Document HOS_CORES defaults**: Updated gpu/vk/switches.def:36 and docs/dev/reference/switches.md:333 with the platform-dependent default and game override. **Left for the author** - **Defaults on unmeasured configurations**: The author must measure the core-count and scheduler defaults on the other supported configurations and decide whether they are appropriate. Restoring the previous defaults would reverse the pull request's change. - **Windows process priority default**: The author must measure the priority default with competing work and on other CPU configurations, then decide whether to retain it. Restoring normal priority by default would reverse the pull request's change. Nothing was built or run: the checks run again on the new head. The change raises Windows process priority, selects eight virtual cores on systems reporting at least eight logical processors, and reduces scheduler scanning and polling. The fix wakes waiters when scheduling choices change, but the performance gain and costs of the combined change remain unproven. **Testing before merging (3)** (runs on the systems it can change; it doesn't hold the recommendation) - **L3** `host/hos_thread.c:2144`: The game measurements do not include the scheduler change against main. *When:* Both reported FPS configurations run the PR binary, so the faster bit scan and longer waits occur on both sides. Their combined effect on game frame times remains unknown. **Do:** Compare the base commit and this head with the same player-representative settings and route, using interleaved runs and reporting average FPS and frame-time tails. - **L4** `host/hos_thread.c:174`: The new core-count and scheduler defaults need coverage on the other supported systems they affect. *When:* Linux and Steam Deck also select the new core count and use the changed scheduler, but the supplied runs cover only an eight-thread Windows PC. Different CPU capacity and contention can change frame pacing. **Do:** Use the Test Farm to compare base and head in game on Linux, Steam Deck and representative Tier 1 hardware, including frame-time tails and scheduler waits. - **L5** `host/hos_thread.c:615`: The Windows priority default has not been evaluated with competing work or on other CPU configurations. *When:* Above-normal process priority also raises the scheduling priority of ordinary host threads relative to normal-priority applications, so a busy machine can behave differently from the tested setup. **Do:** Compare base and head on representative Windows CPUs with normal background work, recording game frame-time tails and responsiveness of competing work. **Checks:** they run again on this head; a failure shows on the pull request. <details> <summary>Also noticed (1; not asked for, not blocking)</summary> - The base-to-head diff contains changes from other commits beyond the files listed in the pull request. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven against main. Two runs per setting on the PR binary report average FPS rising from 92.45 to 103.44 and 1% lows from 40.44 to 60.89 on one Windows PC; that comparison excludes the scheduler change relative to main. **Other systems:** The core-count default and scheduler affect Windows and Linux, including different CPU configurations and Steam Deck. Process priority affects Windows and competing applications; the supplied results cover one Windows CPU and do not establish those other effects. **Switches:** HOS_PROCESS_PRIORITY is added with default 1 on Windows; HOS_CORES changes from 6 to auto-select 8 when the OS reports at least eight logical processors, otherwise 6, subject to a game override when unset. The defaults need the measurements in L4 and L5; their documentation is updated. **Reviewed:** 4e5562c1ff6c against 19f9da05eac9: Read the repository agent and contributing rules, pull request template, fix diff, scheduler sections of host/hos_thread.c, and tests/test_vcore_escape.py. Skimmed the broader base-to-head diff and commit list; the base-to-head diff includes many files beyond the listed PR files, and those files were not read in full. docs/review-checklist.md was absent.; nothing run (a code review). **Checked and fine:** - The fix wakes registered waiters after priority changes and wakes an affected queued waiter after affinity changes. - Unregistered waiters retain one-millisecond polling. - The core-count documentation states the OS-dependent default and game override. **Testing:** The author reports Windows game runs and targeted checks; Linux and full Windows runs remain outstanding. CI has not run on this head. No commands from the project were run during this review. **Overlaps and merge order:** The base-to-head commit list includes other merged pull requests; their merge status and overlap with this branch were not established. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.</sub>
HumanBean deleted branch perf/pc-phase-c-threading-parallel 2026-12-01 00:44:44 +00:00
Author
Contributor

Follow-up now that this is merged (f439f2bb9, 1 Dec), covering BeanBot's open items and the measurements that have come in since.

L1 (blocking, waiter not woken on affinity/priority change): @fix resolved this before the merge:

  • vc_set_affinity wakes a queued waiter (host/hos_thread.c:2193).
  • vc_thread_priority wakes every queued waiter under vc_lock (host/hos_thread.c:2061).
  • A woken waiter re-checks before it escapes (if (woken) continue;, host/hos_thread.c:2372).
  • A thread that didn't fit in the 1024-slot queue still polls every 1 ms (host/hos_thread.c:2359).

@fix added behavioural cases to tests/test_vcore_escape.py without running them, so I ran them on main (Testing below). From reading the code, one cost remains: GetThreadPriority (set == 0) now takes vc_lock exclusively just to read. It's harmless for correctness, and I'll only change it if a profile shows the lock.

L2 (switch docs): done by @fix. Since then the mod-API merge moved HOS_CORES to the system/thread-settings:host_cores setting, and hos_cores() on main keeps the same rule (host/hos_thread.c:190-205: 8 when the PC reports ≥ 8 logical processors, else 6, game override when unset).

L3 (scheduler change against main), L4 (other systems), L5 (priority with competing work): these are where the evidence is weakest, and I'll say so plainly.

  • My numbers compared HOS_PROCESS_PRIORITY=0 HOS_CORES=6 against the defaults on the same PR binary, on one i7-9700 (8C/8T) / RTX 4060. As BeanBot says, the vc_acquire scan and wait change was on both sides, so it was never measured against main.
  • HumanBean has since measured each part alone on an RTX 3090 / 24-thread Linux PC, ported onto main (#2886 comment):
    • 8 cores: −0.2 % fps (159.4 / 156.7 → 159.4 / 155.9).
    • Deadline wait: +0.2 % (mean vcore wait 57 vs 56 µs).
    • Both are inside the 155.9–160.3 fps spread of those runs: neutral, not slower.
    • Process priority is _WIN32-only, so that PC couldn't test it.
  • The farm run HumanBean started on be34542 was cancelled before any report (dashboard). So nothing has run on Steam Deck, on AMD/Intel CPUs, or on a Windows PC with background load (L5).

The defaults stay as merged for now. No system has shown them slower, and our rule changes a shipped default only when a reviewer asks or ≥ 2 systems show it slower. But the merged description's "+11.9 % avg / +50.6 % 1 % low" is a single-PC result that one other system did not reproduce. The places it could matter, either way, are CPUs with 6–8 threads (where 8 virtual cores means oversubscription), Steam Deck, and Windows with competing work for the priority class. These need the farm or testers. If either default turns out slower on two systems, I'll open the PR that reverts it.

CI on the head: "Game-free checks" 1/2 and 2/2, "Website" and "Third-party parts" failed on 4e5562c. The same four checks also failed on main's own push runs at the merges around it (19f9da05e, f439f2bb9, 018dd2ef4) until #3057 fixed main's checks.

Testing (this comment): on a clean main @ b4d56f526 worktree, Windows / llvm-mingw:

  • tests/test_vcore_escape.py (with @fix's new cases), test_vcore_fs_open, test_vcore_mask0, test_reserved_core, test_reserved_core_mask, test_short_sleep_timer, test_spin_by_role, test_thread_wake_cleanup: 8 of 8 pass (python -I -B tests/run_all.py --exact ...).
  • tests/test_invalidate_vcore.py (compiles hos_vcore_away / hos_vcore_back from host/hos_thread.c): the vulkan case passes. The fallback case failed at its 2 s wait for the producer thread (tests/invalidate_vcore_test.cpp:122), with the check at below-normal priority on a fully loaded PC. I can't rule out the longer vc_acquire sleep from here. It needs a rerun on an idle PC or in CI, and I'll follow up if it fails there.
Follow-up now that this is merged (f439f2bb9, 1 Dec), covering BeanBot's open items and the measurements that have come in since. **L1 (blocking, waiter not woken on affinity/priority change):** `@fix` resolved this before the merge: - `vc_set_affinity` wakes a queued waiter (`host/hos_thread.c:2193`). - `vc_thread_priority` wakes every queued waiter under `vc_lock` (`host/hos_thread.c:2061`). - A woken waiter re-checks before it escapes (`if (woken) continue;`, `host/hos_thread.c:2372`). - A thread that didn't fit in the 1024-slot queue still polls every 1 ms (`host/hos_thread.c:2359`). `@fix` added behavioural cases to `tests/test_vcore_escape.py` without running them, so I ran them on `main` (Testing below). From reading the code, one cost remains: `GetThreadPriority` (`set == 0`) now takes `vc_lock` exclusively just to read. It's harmless for correctness, and I'll only change it if a profile shows the lock. **L2 (switch docs):** done by `@fix`. Since then the mod-API merge moved `HOS_CORES` to the `system/thread-settings:host_cores` setting, and `hos_cores()` on `main` keeps the same rule (`host/hos_thread.c:190-205`: 8 when the PC reports ≥ 8 logical processors, else 6, game override when unset). **L3 (scheduler change against main), L4 (other systems), L5 (priority with competing work):** these are where the evidence is weakest, and I'll say so plainly. - My numbers compared `HOS_PROCESS_PRIORITY=0 HOS_CORES=6` against the defaults on the same PR binary, on one i7-9700 (8C/8T) / RTX 4060. As BeanBot says, the `vc_acquire` scan and wait change was on both sides, so it was never measured against `main`. - HumanBean has since measured each part alone on an RTX 3090 / 24-thread Linux PC, ported onto `main` ([#2886 comment](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2886)): - 8 cores: −0.2 % fps (159.4 / 156.7 → 159.4 / 155.9). - Deadline wait: +0.2 % (mean vcore wait 57 vs 56 µs). - Both are inside the 155.9–160.3 fps spread of those runs: neutral, not slower. - Process priority is `_WIN32`-only, so that PC couldn't test it. - The farm run HumanBean started on `be34542` was cancelled before any report ([dashboard](https://beanstalk.magicbean.dev/prs/2876)). So nothing has run on Steam Deck, on AMD/Intel CPUs, or on a Windows PC with background load (L5). The defaults stay as merged for now. No system has shown them slower, and our rule changes a shipped default only when a reviewer asks or ≥ 2 systems show it slower. But the merged description's "+11.9 % avg / +50.6 % 1 % low" is a single-PC result that one other system did not reproduce. The places it could matter, either way, are CPUs with 6–8 threads (where 8 virtual cores means oversubscription), Steam Deck, and Windows with competing work for the priority class. These need the farm or testers. If either default turns out slower on two systems, I'll open the PR that reverts it. **CI on the head:** "Game-free checks" 1/2 and 2/2, "Website" and "Third-party parts" failed on `4e5562c`. The same four checks also failed on `main`'s own push runs at the merges around it (19f9da05e, f439f2bb9, 018dd2ef4) until #3057 fixed `main`'s checks. **Testing (this comment):** on a clean `main` @ `b4d56f526` worktree, Windows / llvm-mingw: - `tests/test_vcore_escape.py` (with `@fix`'s new cases), `test_vcore_fs_open`, `test_vcore_mask0`, `test_reserved_core`, `test_reserved_core_mask`, `test_short_sleep_timer`, `test_spin_by_role`, `test_thread_wake_cleanup`: **8 of 8 pass** (`python -I -B tests/run_all.py --exact ...`). - `tests/test_invalidate_vcore.py` (compiles `hos_vcore_away` / `hos_vcore_back` from `host/hos_thread.c`): the `vulkan` case passes. The `fallback` case **failed** at its 2 s wait for the producer thread (`tests/invalidate_vcore_test.cpp:122`), with the check at below-normal priority on a fully loaded PC. I can't rule out the longer `vc_acquire` sleep from here. It needs a rerun on an idle PC or in CI, and I'll follow up if it fails there.
Some checks failed
beanstalk/approval not approved yet
PR description / Title and description (pull_request_target) Failing after 6s
CI / What the change needs (pull_request) Successful in 8s
CI / Third-party parts and guide screenshots (pull_request) Failing after 10s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 17s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Successful in 4m10s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 2m12s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 4m46s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 4m44s
CI / Website build and checks (pull_request) Failing after 36s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 21m55s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 38m35s
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
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
MagicBeanDev/Longshot!2876
No description provided.