The title's thread affinities on the fast cores first (Intel hybrid CPUs) #419

Open
github-bot wants to merge 1 commit from github-bot/gh-419 into main AGit
Owner

@⁠justrealyme on GitHub · 2026-11-27 22:09 UTC · original
justrealyme:title-affinity-fast-cores → main · +192 −0 · 2 files · 1 commits · open

Problem

The title pins its threads by processor number with SetThreadGroupAffinity, as it would on the console, where all eight cores are the same. The call went straight to the host. On a CPU with two kinds of core, those numbers land on a mix of fast and slow cores.

On an Intel Core Ultra 7 265K, the fast cores (P-cores) are logical processors 0, 1, 6-9, 18 and 19. A thread dump in the prison cell showed:

Title threads Mask asked On this CPU
~9 busy workers at "highest" 0xFF (0-7) 4 fast + 4 slow cores
~8 threads 0x1F00 (8-12) 2 fast + 3 slow
1 "time critical" thread, ~35% busy 0x2000 (13 alone) one slow core

The layer's own threads already keep to the fast cores (cores.rs). The title's own threads didn't.

Change

SetThreadGroupAffinity from api-ms-win-core-processtopology-* is now handled by modules::kernel, next to the existing SetThreadPriority override. VICTORY_TITLE_AFFINITY has three settings:

  • fast (default): the title's processor i becomes the host's i-th fastest, ordered by efficiency class and then by number (GetSystemCpuSetInformation, group 0). On the 265K the title's 0-7 become the eight fast cores. On a CPU where all cores are alike (a Ryzen without E-cores, for example), the order is the host's own and every mask stays unchanged.
  • free: the call is answered as done (with the previous affinity) and the thread is left to the Windows scheduler.
  • keep: as before.

A unit test covers the 265K layout and the all-cores-alike case. The only other change is the Win32_System_SystemInformation feature for victory-hle.

Validation

Core Ultra 7 265K, RTX 5070 Ti (driver 621.40), 31 GB RAM, Windows 11. Release build, play-nvidia.ps1 defaults (Series X, 1440p, DLSS Quality), same scripted route into the prison cell, presents per second from 140 to 205 s, caches warm. Before / after:

before (keep) after (fast)
mean fps 24.6 24.8
10th percentile / lowest second 23 / 6 24 / 23
card idle while the title hadn't submitted 3.7 ms/frame 0.1 ms/frame
card idle behind the submitting thread 9.7 ms/frame 12.8 ms/frame

What it does: the title-side waits are gone and the dips are smaller. What it doesn't do: raise the average on this CPU, because the submitting thread is the next limit. The fps figures are from one run each, and the same route varies by about ±3 fps between runs, so read the mean as "unchanged". The internal timings are the clearer signal.

  • Measured on f3534e6, rebased onto df2daaf, rebuilt, and confirmed to run. Not re-measured on the new base.
  • cargo test -p victory-hle: all pass (175 + the rest).
  • cargo clippy -p victory-hle --all-targets: nothing in the changed file. With -D warnings it stops on existing victory-gpu findings (dead code in host/indirects.rs, among others), which are there on main as well.
  • Also tried, not included: putting the layer's own helpers on the fast cores too (VICTORY_FAST_CORES=3) made no difference.

Done with AI assistance (Claude Code). No game data is included.

🤖 Generated with Claude Code

**@⁠justrealyme** on GitHub · 2026-11-27 22:09 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/419) `justrealyme:title-affinity-fast-cores` → `main` · +192 −0 · 2 files · 1 commits · open ## Problem The title pins its threads by processor number with `SetThreadGroupAffinity`, as it would on the console, where all eight cores are the same. The call went straight to the host. On a CPU with two kinds of core, those numbers land on a mix of fast and slow cores. On an Intel Core Ultra 7 265K, the fast cores (P-cores) are logical processors 0, 1, 6-9, 18 and 19. A thread dump in the prison cell showed: | Title threads | Mask asked | On this CPU | |---|---|---| | ~9 busy workers at "highest" | `0xFF` (0-7) | 4 fast + 4 slow cores | | ~8 threads | `0x1F00` (8-12) | 2 fast + 3 slow | | 1 "time critical" thread, ~35% busy | `0x2000` (13 alone) | one slow core | The layer's own threads already keep to the fast cores (`cores.rs`). The title's own threads didn't. ## Change `SetThreadGroupAffinity` from `api-ms-win-core-processtopology-*` is now handled by `modules::kernel`, next to the existing `SetThreadPriority` override. `VICTORY_TITLE_AFFINITY` has three settings: - `fast` (default): the title's processor `i` becomes the host's `i`-th fastest, ordered by efficiency class and then by number (`GetSystemCpuSetInformation`, group 0). On the 265K the title's 0-7 become the eight fast cores. On a CPU where all cores are alike (a Ryzen without E-cores, for example), the order is the host's own and every mask stays unchanged. - `free`: the call is answered as done (with the previous affinity) and the thread is left to the Windows scheduler. - `keep`: as before. A unit test covers the 265K layout and the all-cores-alike case. The only other change is the `Win32_System_SystemInformation` feature for `victory-hle`. ## Validation Core Ultra 7 265K, RTX 5070 Ti (driver 621.40), 31 GB RAM, Windows 11. Release build, `play-nvidia.ps1` defaults (Series X, 1440p, DLSS Quality), same scripted route into the prison cell, presents per second from 140 to 205 s, caches warm. Before / after: | | before (`keep`) | after (`fast`) | |---|---|---| | mean fps | 24.6 | 24.8 | | 10th percentile / lowest second | 23 / 6 | 24 / 23 | | card idle while the title hadn't submitted | 3.7 ms/frame | 0.1 ms/frame | | card idle behind the submitting thread | 9.7 ms/frame | 12.8 ms/frame | What it does: the title-side waits are gone and the dips are smaller. What it doesn't do: raise the average on this CPU, because the submitting thread is the next limit. The fps figures are from one run each, and the same route varies by about ±3 fps between runs, so read the mean as "unchanged". The internal timings are the clearer signal. - Measured on f3534e6, rebased onto df2daaf, rebuilt, and confirmed to run. Not re-measured on the new base. - `cargo test -p victory-hle`: all pass (175 + the rest). - `cargo clippy -p victory-hle --all-targets`: nothing in the changed file. With `-D warnings` it stops on existing `victory-gpu` findings (dead code in `host/indirects.rs`, among others), which are there on main as well. - Also tried, not included: putting the layer's own helpers on the fast cores too (`VICTORY_FAST_CORES=3`) made no difference. Done with AI assistance (Claude Code). No game data is included. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The title pins its threads by processor number, as on the console's eight
cores that are all alike: its busiest workers to 0-7, one "time critical"
thread to 13 alone. SetThreadGroupAffinity went straight to the host, so on
a processor with two kinds of core those numbers were a mix: on a Core Ultra
7 265K (fast cores 0, 1, 6-9, 18, 19) the workers' 0-7 held four slow
cores and 13 is a slow one.

SetThreadGroupAffinity is now ours: `fast` (the default) maps the title's
processor i onto the host's i-th fastest (by efficiency class, then
number), `free` leaves the threads to the host's scheduler, `keep` applies
the masks as asked. Where all cores are alike the order is the host's own
and the masks are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 22:14:34 +00:00
Author
Owner

@⁠fromrivertothesea on GitHub · 2026-11-28 00:23 UTC · original

Measured on a different hybrid CPU, for comparison: i5-12600KF (6 P-cores + 4 E-cores), RTX 5070 Ti, 32 GB, GTA VI 1.0.2.1, first playable part (the prison cell), Series X profile, DLSS Quality, frame generation not prepared (-NoFrameGenReady). Same build both times (this PR merged in); the only difference is VICTORY_TITLE_AFFINITY. Medians over 90 s of settled gameplay:

VICTORY_TITLE_AFFINITY fps (median) range card busy
keep 20.3 11.9–24.9 65%
fast (default) 18.9 13.7–23.0 57%

So no gain here; the difference is within run-to-run noise. On this PC the frame is limited by the submitting thread's own work (about 43 ms per frame preparing, mostly refreshes of title buffers), and that thread is the layer's, which cores.rs already keeps on fast cores.

One thing to look at: the first run with this PR crashed once while loading, at frame 11463, with draw.rs:128: index out of bounds: the len is 5 but the index is 17 in TableGroup::entry, on a list thread (list::thin::run_plain). A TablePlan can't hold that index as built, so it reads like a stale pipeline pointer or a race. That build also had #378 merged in, the crash happened only once, and the later run with this PR on didn't crash, so I can't say this PR causes it. It may just be the different thread timing exposing something older.

🤖 Generated with Claude Code

**@⁠fromrivertothesea** on GitHub · 2026-11-28 00:23 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/419#issuecomment-7230879043) Measured on a different hybrid CPU, for comparison: **i5-12600KF** (6 P-cores + 4 E-cores), RTX 5070 Ti, 32 GB, GTA VI 1.0.2.1, first playable part (the prison cell), Series X profile, DLSS Quality, frame generation not prepared (`-NoFrameGenReady`). Same build both times (this PR merged in); the only difference is `VICTORY_TITLE_AFFINITY`. Medians over 90 s of settled gameplay: | `VICTORY_TITLE_AFFINITY` | fps (median) | range | card busy | |---|---|---|---| | `keep` | 20.3 | 11.9–24.9 | 65% | | `fast` (default) | 18.9 | 13.7–23.0 | 57% | So no gain here; the difference is within run-to-run noise. On this PC the frame is limited by the submitting thread's own work (about 43 ms per frame preparing, mostly refreshes of title buffers), and that thread is the layer's, which `cores.rs` already keeps on fast cores. One thing to look at: the first run with this PR crashed once while loading, at frame 11463, with `draw.rs:128: index out of bounds: the len is 5 but the index is 17` in `TableGroup::entry`, on a list thread (`list::thin::run_plain`). A `TablePlan` can't hold that index as built, so it reads like a stale pipeline pointer or a race. That build also had #378 merged in, the crash happened only once, and the later run with this PR on didn't crash, so I can't say this PR causes it. It may just be the different thread timing exposing something older. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/419/head:github-bot/gh-419'
git switch 'github-bot/gh-419'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-419'
git switch 'github-bot/gh-419'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-419'
git switch 'github-bot/gh-419'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-419'
git switch 'main'
git merge --squash 'github-bot/gh-419'
git switch 'main'
git merge --ff-only 'github-bot/gh-419'
git switch 'main'
git merge 'github-bot/gh-419'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.