WIP: perf(os): each virtual core's owner slot on its own cache line #1973

Closed
siantm wants to merge 2 commits from siantm/Longshot:perf/vcore-owner-lines into main
Contributor

Summary

Depends on #1972 (perf/vcore-fast, the HOS_VCORE_FAST pull request): this branch is that one plus one
commit. Its commit shows in this diff until it merges; only the last commit is this change.

With HOS_VCORE_FAST=1 a holder takes and frees its core's slot in vc_owner without vc_lock. The eight slots are
eight pointers on one 64-byte cache line, so each take and each release on one core takes the line from the holders of
all the others, who are taking and releasing their own slots at the same time.

This puts each slot on a cache line of its own: vc_owner[8] becomes eight 64-byte-aligned slots (.t). The atomics
and their orders are unchanged. With HOS_VCORE_FAST off every write is under vc_lock, and nothing changes but 512
bytes instead of 64. No switch.

From cafb4100 (its host/hos_thread.c half) on exp/x86-asm-sync.

Read first: vc_owner and vc_holder in host/hos_thread.c.

Testing

Tested: Windows 11, i7-9700, RTX 4060 (NVIDIA 610.88), llvm-mingw clang 23.1.5; game-free checks and a
micro-benchmark only. This change has not run in the game on this PC yet (Still to test). Each check
ran in a hidden console of its own, through the PC's job queue (batch 8), on this branch rebased onto main @ 2e1f6c32
(head 57257d0d, on perf/vcore-fast 3e65cad4):

  • python -I -B tests/test_vcore_escape.py --cxx clang++: exit 0, "the defaults: ok", "the defaults,
    HOS_VCORE_STARVE_US=0: ok", "HOS_VCORE_FAST=1: ok", "HOS_VCORE_FAST=1, HOS_VCORE_STARVE_US=0: ok"; its layout check
    (64 bytes a slot, the array on a line boundary) is part of it. On main @ 2e1f6c32 it does not build (its fixture
    declares hos_fps_timing twice).
  • python -I -B tests/test_vcore_mask0.py --cxx clang++: exit 0, "the defaults: ok", "HOS_VCORE_FAST=1: ok". On
    main @ 2e1f6c32 it does not build (no env_on_or in its fixture).
  • python -I -B tests/test_switch_table.py --cxx clang++: exit 0, "ok: 735 switches (diag 295, tune 109, kill 129,
    attempt 81, hw 67, player 54), 144 removed, 743 names read".
  • python -I -B tests/run_all.py --strict --changed origin/main (5 files changed with perf/vcore-fast, 54 checks
    read them): exit 1, "44 passed, 11 failed, 4 skipped". test_vcore_escape, test_vcore_mask0, test_switch_table,
    test_invalidate_vcore, test_reserved_core, test_reserved_core_mask, test_short_sleep_timer and
    test_spin_by_role pass. All 11 failures fail on main @ 2e1f6c32 too (run by name in the same batch):
    test_crash_dialog, test_crash_record, test_dev_ab, test_dev_packs, test_frame_overlap,
    test_linux_pressure, test_present_queue_default, test_profiling_mode, test_slow_frames,
    test_target_reuse_memory, test_vk_occlusion_queries.

The branch was then rebased onto main @ 6e1521a7 unchanged (git range-diff: "=" for both commits, head 8f250090,
on perf/vcore-fast e6acd10c); main's commits since 2e1f6c32 touch none of its files, so the checks were not run
again there.

Still to test:

  • Windows 11, this PC (i7-9700, RTX 4060 (NVIDIA 610.88)): Castle Town's market, this PR's build with
    HOS_VCORE_FAST=1 against unset, at least two interleaved runs each, expecting the log line "vcores: takes and
    releases without vc_lock while nobody waits (HOS_VCORE_FAST)" with it set, no "ran without a core" line, no crash,
    and fps and frame times within the runs' spread or better (by hand)
  • Linux: build the host and run python3 -I -B tests/test_vcore_escape.py, expecting it to pass with
    HOS_VCORE_FAST off and on (by hand)
  • PCs with 6 or fewer logical processors, and the Steam Deck: the game in a busy area with HOS_VCORE_FAST=1 against
    unset on this PR, expecting frame times within the runs' spread or better and no "ran without a core" line
    (@Beanstalk play Castle Town's market for two minutes on PCs with 6 or fewer logical processors and on the Steam
    Deck, this PR with HOS_VCORE_FAST=1 against unset, comparing frame times and looking for "ran without a core" in the
    log)

Measurements

Verdict: a micro-benchmark only; no play measurement exists yet. In this micro-benchmark, with HOS_VCORE_FAST=1
a take and a release cost 74-89 % less than on perf/vcore-fast, and 67-89 % less than the locked path
(HOS_VCORE_FAST unset: 170.1, 366.5, 587.0 ns at 2, 4, 6 threads).

Baseline: perf/vcore-fast (the pull request this one depends on), as main has no HOS_VCORE_FAST; both with
HOS_VCORE_FAST=1.
Setup: Windows 11, i7-9700 (8 cores, no SMT), llvm-mingw clang++ 23.1.5, -O2; micro-benchmark: host/hos_thread.c's
vcore block compiled with Windows' SRW locks, 2, 4 and 6 threads each taking and giving up its own core
(hos_vcore_back, hos_vcore_away) with 8 virtual cores, so nobody waits; 15 interleaved rounds of 400 ms, the median
and the rounds' range; one timing job of the PC's queue. Measured at 15e55f96 and 026a1abc, these commits on main @
51f5f9da; their rebases since, now onto 6e1521a7, changed none of their lines (git range-diff "=").

Before, HOS_VCORE_FAST=1: perf/vcore-fast @ 15e55f96 After, HOS_VCORE_FAST=1: this PR @ 026a1abc
micro-benchmark, ns per take+release, 2 threads 218.5 (199.8-236.4) 56.0 (53.6-66.4), -74 %
micro-benchmark, 4 threads 436.3 (407.6-464.3) 59.0 (56.2-68.1), -87 %
micro-benchmark, 6 threads 633.7 (603.6-739.2) 67.2 (61.6-85.6), -89 %
ns per take+release pair, per thread (median of 15 rounds of 400 ms; min-max)
  2 threads  fast-H1        218.5 ns  (199.8-236.4)    +0.0 % vs fast-H1
  2 threads  fast-H2         56.0 ns  (53.6-66.4)   -74.4 % vs fast-H1
  2 threads  locked-H1      170.1 ns  (161.9-200.6)   -22.2 % vs fast-H1
  4 threads  fast-H1        436.3 ns  (407.6-464.3)    +0.0 % vs fast-H1
  4 threads  fast-H2         59.0 ns  (56.2-68.1)   -86.5 % vs fast-H1
  4 threads  locked-H1      366.5 ns  (345.9-391.0)   -16.0 % vs fast-H1
  6 threads  fast-H1        633.7 ns  (603.6-739.2)    +0.0 % vs fast-H1
  6 threads  fast-H2         67.2 ns  (61.6-85.6)   -89.4 % vs fast-H1
  6 threads  locked-H1      587.0 ns  (561.4-621.5)    -7.4 % vs fast-H1

(fast-H1: perf/vcore-fast 15e55f96 with HOS_VCORE_FAST=1; fast-H2: this PR, 026a1abc, with it; locked-H1:
perf/vcore-fast with it unset.)

Risks

Nothing changes in what the scheduler does; 448 more bytes of static data. A mistake in the layout would show as a
build error (every access goes through .t) or a failed layout check. A revert is enough. Players notice nothing.

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 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 Depends on #1972 (`perf/vcore-fast`, the `HOS_VCORE_FAST` pull request): this branch is that one plus one commit. Its commit shows in this diff until it merges; only the last commit is this change. With `HOS_VCORE_FAST=1` a holder takes and frees its core's slot in `vc_owner` without `vc_lock`. The eight slots are eight pointers on one 64-byte cache line, so each take and each release on one core takes the line from the holders of all the others, who are taking and releasing their own slots at the same time. This puts each slot on a cache line of its own: `vc_owner[8]` becomes eight 64-byte-aligned slots (`.t`). The atomics and their orders are unchanged. With `HOS_VCORE_FAST` off every write is under `vc_lock`, and nothing changes but 512 bytes instead of 64. No switch. From cafb4100 (its `host/hos_thread.c` half) on `exp/x86-asm-sync`. Read first: `vc_owner` and `vc_holder` in `host/hos_thread.c`. ## Testing **Tested:** Windows 11, i7-9700, RTX 4060 (NVIDIA 610.88), llvm-mingw clang 23.1.5; game-free checks and a micro-benchmark only. This change has not run in the game on this PC yet (Still to test). Each check ran in a hidden console of its own, through the PC's job queue (batch 8), on this branch rebased onto `main` @ 2e1f6c32 (head 57257d0d, on `perf/vcore-fast` 3e65cad4): - `python -I -B tests/test_vcore_escape.py --cxx clang++`: exit 0, "the defaults: ok", "the defaults, HOS_VCORE_STARVE_US=0: ok", "HOS_VCORE_FAST=1: ok", "HOS_VCORE_FAST=1, HOS_VCORE_STARVE_US=0: ok"; its layout check (64 bytes a slot, the array on a line boundary) is part of it. On `main` @ 2e1f6c32 it does not build (its fixture declares `hos_fps_timing` twice). - `python -I -B tests/test_vcore_mask0.py --cxx clang++`: exit 0, "the defaults: ok", "HOS_VCORE_FAST=1: ok". On `main` @ 2e1f6c32 it does not build (no `env_on_or` in its fixture). - `python -I -B tests/test_switch_table.py --cxx clang++`: exit 0, "ok: 735 switches (diag 295, tune 109, kill 129, attempt 81, hw 67, player 54), 144 removed, 743 names read". - `python -I -B tests/run_all.py --strict --changed origin/main` (5 files changed with `perf/vcore-fast`, 54 checks read them): exit 1, "44 passed, 11 failed, 4 skipped". `test_vcore_escape`, `test_vcore_mask0`, `test_switch_table`, `test_invalidate_vcore`, `test_reserved_core`, `test_reserved_core_mask`, `test_short_sleep_timer` and `test_spin_by_role` pass. All 11 failures fail on `main` @ 2e1f6c32 too (run by name in the same batch): `test_crash_dialog`, `test_crash_record`, `test_dev_ab`, `test_dev_packs`, `test_frame_overlap`, `test_linux_pressure`, `test_present_queue_default`, `test_profiling_mode`, `test_slow_frames`, `test_target_reuse_memory`, `test_vk_occlusion_queries`. The branch was then rebased onto `main` @ 6e1521a7 unchanged (`git range-diff`: "=" for both commits, head 8f250090, on `perf/vcore-fast` e6acd10c); `main`'s commits since 2e1f6c32 touch none of its files, so the checks were not run again there. **Still to test:** - Windows 11, this PC (i7-9700, RTX 4060 (NVIDIA 610.88)): Castle Town's market, this PR's build with `HOS_VCORE_FAST=1` against unset, at least two interleaved runs each, expecting the log line "vcores: takes and releases without vc_lock while nobody waits (HOS_VCORE_FAST)" with it set, no "ran without a core" line, no crash, and fps and frame times within the runs' spread or better (by hand) - Linux: build the host and run `python3 -I -B tests/test_vcore_escape.py`, expecting it to pass with `HOS_VCORE_FAST` off and on (by hand) - PCs with 6 or fewer logical processors, and the Steam Deck: the game in a busy area with `HOS_VCORE_FAST=1` against unset on this PR, expecting frame times within the runs' spread or better and no "ran without a core" line (@Beanstalk play Castle Town's market for two minutes on PCs with 6 or fewer logical processors and on the Steam Deck, this PR with HOS_VCORE_FAST=1 against unset, comparing frame times and looking for "ran without a core" in the log) ## Measurements **Verdict:** a micro-benchmark only; no play measurement exists yet. In this micro-benchmark, with `HOS_VCORE_FAST=1` a take and a release cost 74-89 % less than on `perf/vcore-fast`, and 67-89 % less than the locked path (`HOS_VCORE_FAST` unset: 170.1, 366.5, 587.0 ns at 2, 4, 6 threads). Baseline: `perf/vcore-fast` (the pull request this one depends on), as `main` has no `HOS_VCORE_FAST`; both with `HOS_VCORE_FAST=1`. Setup: Windows 11, i7-9700 (8 cores, no SMT), llvm-mingw clang++ 23.1.5, `-O2`; micro-benchmark: `host/hos_thread.c`'s vcore block compiled with Windows' SRW locks, 2, 4 and 6 threads each taking and giving up its own core (`hos_vcore_back`, `hos_vcore_away`) with 8 virtual cores, so nobody waits; 15 interleaved rounds of 400 ms, the median and the rounds' range; one timing job of the PC's queue. Measured at 15e55f96 and 026a1abc, these commits on `main` @ 51f5f9da; their rebases since, now onto 6e1521a7, changed none of their lines (`git range-diff` "="). | | Before, HOS_VCORE_FAST=1: perf/vcore-fast @ 15e55f96 | After, HOS_VCORE_FAST=1: this PR @ 026a1abc | |---|---|---| | micro-benchmark, ns per take+release, 2 threads | 218.5 (199.8-236.4) | 56.0 (53.6-66.4), -74 % | | micro-benchmark, 4 threads | 436.3 (407.6-464.3) | 59.0 (56.2-68.1), -87 % | | micro-benchmark, 6 threads | 633.7 (603.6-739.2) | 67.2 (61.6-85.6), -89 % | ``` ns per take+release pair, per thread (median of 15 rounds of 400 ms; min-max) 2 threads fast-H1 218.5 ns (199.8-236.4) +0.0 % vs fast-H1 2 threads fast-H2 56.0 ns (53.6-66.4) -74.4 % vs fast-H1 2 threads locked-H1 170.1 ns (161.9-200.6) -22.2 % vs fast-H1 4 threads fast-H1 436.3 ns (407.6-464.3) +0.0 % vs fast-H1 4 threads fast-H2 59.0 ns (56.2-68.1) -86.5 % vs fast-H1 4 threads locked-H1 366.5 ns (345.9-391.0) -16.0 % vs fast-H1 6 threads fast-H1 633.7 ns (603.6-739.2) +0.0 % vs fast-H1 6 threads fast-H2 67.2 ns (61.6-85.6) -89.4 % vs fast-H1 6 threads locked-H1 587.0 ns (561.4-621.5) -7.4 % vs fast-H1 ``` (fast-H1: `perf/vcore-fast` 15e55f96 with `HOS_VCORE_FAST=1`; fast-H2: this PR, 026a1abc, with it; locked-H1: `perf/vcore-fast` with it unset.) ## Risks Nothing changes in what the scheduler does; 448 more bytes of static data. A mistake in the layout would show as a build error (every access goes through `.t`) or a failed layout check. A revert is enough. Players notice nothing. ## 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. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [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(os): virtual cores taken and released without vc_lock while no thread waits for one (HOS_VCORE_FAST, off)
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 14s
Website / Website on Cloudflare (pull_request_target) Has been skipped
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
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
e6acd10c72
HOS_VCORE_FAST=1 is an experiment, off by default: nothing measures it yet.
Off, every path is #327's, under vc_lock. On, a take (vc_take_fast) and a
release (vc_release) take no lock while nobody is queued for a core; a
waiter queues first and then looks at the cores again (vc_settle), a release
frees the slot and then reads vc_nq, so one of the two sees the other. A
slot is taken only by a compare-and-swap (vc_take_if_free under the lock).

Over #327's mask rules:
- the fast take picks the core vc_free_for picks (a mask-0 thread's cached
  core first, vc_pref_core) and writes the guest's TLS core cell after a
  successful take (vc_sync_tls);
- a mask change stores the mask and then reads vc_held under vc_lock, the
  fast take stores vc_held and then reads the mask, with a fence in each:
  a change the take missed makes the take ask itself to move (its kick),
  which the next checkpoint does; a same-core change writes the cell only
  while the thread still holds that core (vc_sync_tls_as).
A release no longer waits for the lock, so DestroyThread passes vc_lock once
(vc_exited) before a thread's record is freed. Takes without the lock are
added to the 5 s line 64 at a time.

tests/test_vcore_escape.py runs off and on: no vc_lock for a take and a
release with nobody queued (off: one each), a release, a better waiter's
kick and a yield handing the core to the right waiter, vc_lock never taken
twice, each slot naming its holder; the starvation cases both ways.
tests/test_vcore_mask0.py runs off and on, with a take through
hos_vcore_back (the cached core, the cell) and, on, a mask change that lands
between the take's choice and its take.

From exp/x86-asm-sync d1e33769 (the host-sync integration; vc_take_fast,
vc_settle, vc_exited), rewritten over #327 (a104182b): the branch's take
ignored vc_pref_core, wrote no TLS cell and had no ordering against
vc_note_mask_change.

Assisted-by: Claude Code
perf(os): each virtual core's owner slot on its own cache line
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 16s
Website / Website on Cloudflare (pull_request_target) Has been skipped
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
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
8f250090a5
With HOS_VCORE_FAST a holder takes and frees its core's slot in vc_owner
without vc_lock, so eight slots on one cache line make every take and
release on one core take the line from the holders of the others.
vc_owner[8] becomes eight 64-byte-aligned slots (.t); the atomics and their
orders are unchanged. With HOS_VCORE_FAST off every write is under vc_lock
and nothing changes but the 512 bytes.

tests/test_vcore_escape.py checks the layout (64 bytes a slot, the array on
a line boundary); both vcore checks read the slots through vc_holder or .t.

From exp/x86-asm-sync cafb4100 (its hos_thread.c half); needs
perf/vcore-fast (HOS_VCORE_FAST).

Assisted-by: Claude Code
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 — Related investigation of virtual-core gate contention
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 — Related investigation of virtual-core gate contention
BeanBot left a comment

Recommendation: Request changes. The stacked scheduler change can miss an affinity update, overwrite the guest’s TLS core value with stale data, and race with its own diagnostics. Padding the slots cuts isolated take-and-release time by 74–89%, but gameplay and the cost on the default path are still unproven.

The last commit gives each of the eight virtual-core owner slots its own 64-byte cache line, adding 448 bytes of static data. That is a small, focused improvement to the opt-in fast path. The prerequisite also changes core acquisition, handoff, affinity checks, and profiling, including some work done with the switch unset.

@fix will do (13)

  1. L1 host/hos_thread.c:2145: The mask saved before the search is separate from the mask used to choose a core. (more on the line)
  2. L2 host/hos_thread.c:1895: The affinity store is atomic, but vc_mask, vc_allowed, vc_free_for and hos_thread_core still read core_mask directly. ideal_core is also shared without synchronization. For example, SetThreadCoreMask can update a running target while its unlocked take reads the old mask and new ideal. Use atomic access throughout and pass a consistent affinity snapshot to the selection helpers.
  3. L3 host/hos_thread.c:168: hos_thread_core reads vc_held directly while a fast take or release can update it without vc_lock. The cross-thread GetThreadCoreMask and host-pinning paths can call it during that change. Take one atomic snapshot and use it for both the test and subtraction. Use an atomic snapshot for vc_last too when a remask caller reads it while the target’s fast take updates it.
  4. L4 host/hos_thread.c:1934: vc_sync_tls_as samples the mask before taking tls_slot_lock. (more on the line)
  5. L5 host/hos_thread.c:1881: The fast core preference reads the volatile slot index and its cached value without the lock used for slot allocation and freeing. If another thread frees and reuses the slot between the index snapshot and the cell read, the taker can treat an unrelated TLS value of 1 through 8 as a cached core. Validate the slot and read its cell under tls_slot_lock, and use consistent atomic access to cells that the scheduler and guest can access concurrently.
  6. L6 host/hos_thread.c:2131: The fast CAS exposes the holder before it initializes vc_held_at and resets vc_kick_at. (more on the line)
  7. L7 host/hos_thread.c:2041: The plain read of vc_st.takes and the struct-wide memset can race with a fast taker’s atomic batch addition. A batch arriving during the report can be cleared without appearing in either interval. Keep the counter separate and consume it with one atomic exchange. Flush each thread’s remaining batch on exit if the log is to count those takes too.
  8. L8 (minor) host/hos_thread.c:2099: A waiter that finds a freshly released slot before the releaser gets vc_lock can grant it to another waiter. (more on the line)
  9. L9 tests/test_slow_frames.py:127: The existing source check requires vc_grant(c, t); in vc_release. The assertion matches 6e1521a7 and cannot match this head, where the call takes three arguments and the locked path delegates to a helper. Update the check to verify that the releaser’s identity reaches a waiter on both paths. The earlier reported failure on both builds does not cover this new mismatch.
  10. L10 tests/test_vcore_escape.py:310: The handoff tests only switch simulated threads once the waiter is asleep. (more on the line)
  11. L11 (minor) tests/test_vcore_escape.py:373: Both documented standalone fixture invocations default to clang++ even when CXX selects another compiler. A Linux GCC-only checkout can run the suite through run_all.py but cannot run the proposed standalone check without supplying an extra option. Use the suite’s compiler selection order in both fixtures, with an explicit --cxx taking precedence.
  12. L12 (minor): The Risks section says the locked path changes only in size. Across this stack, the default also changes the owner, held-core and queue stores to sequential consistency and adds an atomic counter update. Describe the full default-path cost separately from the last commit’s layout change, and include the applicable switch checklist entry for the stacked change.
  13. L13 (its part an edit can do) host/hos_thread.c:1823: Keep the original locked operations when the experiment is off to reduce the default-path cost. Make the take, wait and escape counters reliable for the gameplay comparisons.

For the author (1) (a run, a measurement or a decision)

  • L13 (minor) host/hos_thread.c:1823: The proposed head-on versus head-off run compares two scheduler modes and cannot isolate the padding or show what ships versus main. (more on the line)

Checks: Still running: CI / Conventional Commit title (pull_request), CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request), CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request), CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request), CI / Workflow lint (actionlint) (pull_request), CI / Website build and checks (pull_request), Guide screenshots / Guide images and local UI source review (pull_request), Third-party parts / As their notes say (pull_request), Third-party parts / The same as upstream (pull_request), Website / Website on Cloudflare (pull_request).

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

Does it help: Unproven in gameplay. The PR reports 15 interleaved Windows microbenchmark rounds at 15e55f96 and 026a1abc with HOS_VCORE_FAST=1 and no queued waiters. Median take-and-release times fell from 218.5 to 56.0 ns at two threads, 436.3 to 59.0 ns at four, and 633.7 to 67.2 ns at six, with disjoint ranges. The locked comparison used the prerequisite build. There are no gameplay FPS, 1% low, median or p99 frame-time results, and no main-versus-head comparison with the switch unset.

Other systems: The scheduler is shared by Windows and Linux and can affect pacing on any GPU, particularly on PCs with few logical processors and on Steam Deck. Guest sync, file and memory operations, video, and Vulkan waits give up and retake cores through this path. Audio and input can be affected through guest scheduling. Frame Breakdown, Tracy, HOS_CHAIN and long-wait logs also observe it. The diff contains no renderer API, save format, installer, or build-flag changes.

Switches: The last commit adds no switch. #1972 adds HOS_VCORE_FAST as a developer A/B switch, off when unset, with matching entries in switches.def and the reference docs. Off is appropriate while the fast path has correctness issues. The final default still needs gameplay measurements. HOS_VCORES=0 continues to bypass virtual-core scheduling.

Reviewed: 8f250090a5 against 6e1521a70a: Read host/hos_thread.c, both changed test files, both commits and the full diff, plus AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md and the Forgejo template. Read the relevant host startup, affinity, TLS, thread destruction, Linux wait, and source-check code. Skimmed the unchanged switch reference and registry entries, CI definitions, profiling consumers, and reported run output. There was no local docs/review-checklist.md or sibling Tooling checkout. Comments and reviews were empty.; nothing run (a code review).

Checked and fine:

  • The layout assertion checks both the 64-byte stride and the base alignment. Every changed owner access goes through the slot member, and padding leaves the prerequisite’s memory orders intact.
  • The main guest thread initializes the scheduler before guest worker startup. The current DestroyThread caller joins before taking the lifetime barrier, and the changed owner-pointer dereferences are under vc_lock.
  • The fixtures clear inherited HOS_ switches for their executable runs and deliberately test unset and enabled modes. The switch row uses the shared boolean parser and matches the reference docs.
  • Both commits have Assisted-by trailers. The diff has no game-derived artifacts, generated headers, vendor code, path or file-offset changes, external downloads, or new CPU instruction requirements.

Testing: Read-only review. No project code, build, or test was run. The author reports passing Windows fixture and switch-table checks on the earlier equivalent rebase. Linux host build, gameplay, Tier 1 runs, and head CI results are still pending.

Overlaps and merge order: #1972 is the scheduler prerequisite and supplies the fast-path baseline. The repository groups steps in one performance track into one PR, so fold the padding into #1972. If maintainers keep the stack, land #1972 first and rebase #1973 onto it.


Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The stacked scheduler change can miss an affinity update, overwrite the guest’s TLS core value with stale data, and race with its own diagnostics. Padding the slots cuts isolated take-and-release time by 74–89%, but gameplay and the cost on the default path are still unproven. The last commit gives each of the eight virtual-core owner slots its own 64-byte cache line, adding 448 bytes of static data. That is a small, focused improvement to the opt-in fast path. The prerequisite also changes core acquisition, handoff, affinity checks, and profiling, including some work done with the switch unset. **`@fix` will do (13)** 1. **L1** `host/hos_thread.c:2145`: The mask saved before the search is separate from the mask used to choose a core. (more on the line) 2. **L2** `host/hos_thread.c:1895`: The affinity store is atomic, but vc_mask, vc_allowed, vc_free_for and hos_thread_core still read core_mask directly. ideal_core is also shared without synchronization. For example, SetThreadCoreMask can update a running target while its unlocked take reads the old mask and new ideal. Use atomic access throughout and pass a consistent affinity snapshot to the selection helpers. 3. **L3** `host/hos_thread.c:168`: hos_thread_core reads vc_held directly while a fast take or release can update it without vc_lock. The cross-thread GetThreadCoreMask and host-pinning paths can call it during that change. Take one atomic snapshot and use it for both the test and subtraction. Use an atomic snapshot for vc_last too when a remask caller reads it while the target’s fast take updates it. 4. **L4** `host/hos_thread.c:1934`: vc_sync_tls_as samples the mask before taking tls_slot_lock. (more on the line) 5. **L5** `host/hos_thread.c:1881`: The fast core preference reads the volatile slot index and its cached value without the lock used for slot allocation and freeing. If another thread frees and reuses the slot between the index snapshot and the cell read, the taker can treat an unrelated TLS value of 1 through 8 as a cached core. Validate the slot and read its cell under tls_slot_lock, and use consistent atomic access to cells that the scheduler and guest can access concurrently. 6. **L6** `host/hos_thread.c:2131`: The fast CAS exposes the holder before it initializes vc_held_at and resets vc_kick_at. (more on the line) 7. **L7** `host/hos_thread.c:2041`: The plain read of vc_st.takes and the struct-wide memset can race with a fast taker’s atomic batch addition. A batch arriving during the report can be cleared without appearing in either interval. Keep the counter separate and consume it with one atomic exchange. Flush each thread’s remaining batch on exit if the log is to count those takes too. 8. **L8** (minor) `host/hos_thread.c:2099`: A waiter that finds a freshly released slot before the releaser gets vc_lock can grant it to another waiter. (more on the line) 9. **L9** `tests/test_slow_frames.py:127`: The existing source check requires `vc_grant(c, t);` in `vc_release`. The assertion matches 6e1521a7 and cannot match this head, where the call takes three arguments and the locked path delegates to a helper. Update the check to verify that the releaser’s identity reaches a waiter on both paths. The earlier reported failure on both builds does not cover this new mismatch. 10. **L10** `tests/test_vcore_escape.py:310`: The handoff tests only switch simulated threads once the waiter is asleep. (more on the line) 11. **L11** (minor) `tests/test_vcore_escape.py:373`: Both documented standalone fixture invocations default to clang++ even when CXX selects another compiler. A Linux GCC-only checkout can run the suite through run_all.py but cannot run the proposed standalone check without supplying an extra option. Use the suite’s compiler selection order in both fixtures, with an explicit --cxx taking precedence. 12. **L12** (minor): The Risks section says the locked path changes only in size. Across this stack, the default also changes the owner, held-core and queue stores to sequential consistency and adds an atomic counter update. Describe the full default-path cost separately from the last commit’s layout change, and include the applicable switch checklist entry for the stacked change. 13. **L13** (its part an edit can do) `host/hos_thread.c:1823`: Keep the original locked operations when the experiment is off to reduce the default-path cost. Make the take, wait and escape counters reliable for the gameplay comparisons. **For the author (1)** (a run, a measurement or a decision) - **L13** (minor) `host/hos_thread.c:1823`: The proposed head-on versus head-off run compares two scheduler modes and cannot isolate the padding or show what ships versus main. (more on the line) **Checks:** Still running: `CI / Conventional Commit title (pull_request)`, `CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request)`, `CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request)`, `CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request)`, `CI / Workflow lint (actionlint) (pull_request)`, `CI / Website build and checks (pull_request)`, `Guide screenshots / Guide images and local UI source review (pull_request)`, `Third-party parts / As their notes say (pull_request)`, `Third-party parts / The same as upstream (pull_request)`, `Website / Website on Cloudflare (pull_request)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven in gameplay. The PR reports 15 interleaved Windows microbenchmark rounds at 15e55f96 and 026a1abc with HOS_VCORE_FAST=1 and no queued waiters. Median take-and-release times fell from 218.5 to 56.0 ns at two threads, 436.3 to 59.0 ns at four, and 633.7 to 67.2 ns at six, with disjoint ranges. The locked comparison used the prerequisite build. There are no gameplay FPS, 1% low, median or p99 frame-time results, and no main-versus-head comparison with the switch unset. **Other systems:** The scheduler is shared by Windows and Linux and can affect pacing on any GPU, particularly on PCs with few logical processors and on Steam Deck. Guest sync, file and memory operations, video, and Vulkan waits give up and retake cores through this path. Audio and input can be affected through guest scheduling. Frame Breakdown, Tracy, HOS_CHAIN and long-wait logs also observe it. The diff contains no renderer API, save format, installer, or build-flag changes. **Switches:** The last commit adds no switch. #1972 adds HOS_VCORE_FAST as a developer A/B switch, off when unset, with matching entries in switches.def and the reference docs. Off is appropriate while the fast path has correctness issues. The final default still needs gameplay measurements. HOS_VCORES=0 continues to bypass virtual-core scheduling. **Reviewed:** 8f250090a5fc against 6e1521a70a32: Read host/hos_thread.c, both changed test files, both commits and the full diff, plus AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md and the Forgejo template. Read the relevant host startup, affinity, TLS, thread destruction, Linux wait, and source-check code. Skimmed the unchanged switch reference and registry entries, CI definitions, profiling consumers, and reported run output. There was no local docs/review-checklist.md or sibling Tooling checkout. Comments and reviews were empty.; nothing run (a code review). **Checked and fine:** - The layout assertion checks both the 64-byte stride and the base alignment. Every changed owner access goes through the slot member, and padding leaves the prerequisite’s memory orders intact. - The main guest thread initializes the scheduler before guest worker startup. The current DestroyThread caller joins before taking the lifetime barrier, and the changed owner-pointer dereferences are under vc_lock. - The fixtures clear inherited HOS_ switches for their executable runs and deliberately test unset and enabled modes. The switch row uses the shared boolean parser and matches the reference docs. - Both commits have Assisted-by trailers. The diff has no game-derived artifacts, generated headers, vendor code, path or file-offset changes, external downloads, or new CPU instruction requirements. **Testing:** Read-only review. No project code, build, or test was run. The author reports passing Windows fixture and switch-table checks on the earlier equivalent rebase. Linux host build, gameplay, Tier 1 runs, and head CI results are still pending. **Overlaps and merge order:** #1972 is the scheduler prerequisite and supplies the fast-path baseline. The repository groups steps in one performance track into one PR, so fold the padding into #1972. If maintainers keep the stack, land #1972 first and rebase #1973 onto it. </details> --- <sub>Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.</sub>
@ -1818,1 +1821,3 @@
static HosThread *vc_owner[8];
/* (each core's slot on its own cache line: a take or a release on one core does not take the line from the other cores'
holders, whose own takes and releases read and write their slots without vc_lock: HOS_VCORE_FAST) */
static struct { HosThread *t; } __attribute__((aligned(64))) vc_owner[8];
Member

L13 (minor): The proposed head-on versus head-off run compares two scheduler modes and cannot isolate the padding or show what ships versus main. Run warmed, interleaved comparisons of #1972 versus head with fast mode enabled, and main versus head at shipping defaults. Report average FPS, 1% lows, median and p99 frame times in the market and a heavy scene, with the author’s in-game run and coverage on Windows, Linux and Steam Deck.

**L13** (minor): The proposed head-on versus head-off run compares two scheduler modes and cannot isolate the padding or show what ships versus main. Run warmed, interleaved comparisons of #1972 versus head with fast mode enabled, and main versus head at shipping defaults. Report average FPS, 1% lows, median and p99 frame times in the market and a heavy scene, with the author’s in-game run and coverage on Windows, Linux and Steam Deck.
@ -1890,1 +1931,4 @@
did under vc_lock: with HOS_VCORE_FAST, t may have let c go and taken another core without the lock since; that take
stores vc_held before it writes the cell, and a release clears vc_held before it frees the slot) */
static void vc_sync_tls_as(HosThread *t, int c, int held_only) {
const uint32_t mask = vc_mask(t);
Member

L4: vc_sync_tls_as samples the mask before taking tls_slot_lock. A fast taker can sample a multi-bit mask, pause, then overwrite the core number that a concurrent same-core remask to one bit just wrote. No move is requested, so the cell can stay zero until another take. Read the current mask inside the TLS critical section and cover the order where the remask writes first.

**L4**: vc_sync_tls_as samples the mask before taking tls_slot_lock. A fast taker can sample a multi-bit mask, pause, then overwrite the core number that a concurrent same-core remask to one bit just wrote. No move is requested, so the cell can stay zero until another take. Read the current mask inside the TLS critical section and cover the order where the remask writes first.
@ -2026,0 +2096,4 @@
bound is for cores freed again meanwhile, whose releases give them on themselves */
static void vc_settle(HosThread *t, int queued) {
int c;
for (int n = 0; n < 64 && !t->vc_held && (c = vc_free_for(t)) >= 0; n++) {
Member

L8 (minor): A waiter that finds a freshly released slot before the releaser gets vc_lock can grant it to another waiter. That emits a HOS_CHAIN signal from the settling waiter and loses the actual release attribution. Tracy can also print an empty “given by” label for grants with no named releaser. Distinguish claims of an already free slot from release handoffs in the trace and give unnamed grants a valid label.

**L8** (minor): A waiter that finds a freshly released slot before the releaser gets vc_lock can grant it to another waiter. That emits a HOS_CHAIN signal from the settling waiter and loses the actual release attribution. Tracy can also print an empty “given by” label for grants with no named releaser. Distinguish claims of an already free slot from release handoffs in the trace and give unnamed grants a valid label.
@ -2026,0 +2128,4 @@
__atomic_store_n(&t->vc_held, c + 1, __ATOMIC_SEQ_CST);
t->vc_last = c + 1;
t->vc_starved = 0;
t->vc_held_at = hos_now_ns(), t->vc_kick_at = 0; /* (vc_long_wait: how long a holder has held its core) */
Member

L6: The fast CAS exposes the holder before it initializes vc_held_at and resets vc_kick_at. A waiter holding vc_lock can read vc_held_at or write vc_kick_at while the fast taker writes them. A kick recorded just after the CAS can also lose its timestamp. Publish initialized per-take metadata before exposing it to readers, synchronize subsequent updates, and read vc_kick atomically even in diagnostics.

**L6**: The fast CAS exposes the holder before it initializes vc_held_at and resets vc_kick_at. A waiter holding vc_lock can read vc_held_at or write vc_kick_at while the fast taker writes them. A kick recorded just after the CAS can also lose its timestamp. Publish initialized per-take metadata before exposing it to readers, synchronize subsequent updates, and read vc_kick atomically even in diagnostics.
@ -2026,0 +2142,4 @@
ReleaseSRWLockExclusive(&vc_lock);
if (wanted) return 0;
}
if (vc_mask_changed(mask, __atomic_load_n(&t->core_mask, __ATOMIC_RELAXED))) {
Member

L1: The mask saved before the search is separate from the mask used to choose a core. A taker can save mask 1, choose core 1 while the mask is 2, then claim it after the mask returns to 1. Both setters can see no held core, and the final comparison sees 1 on both sides, so the thread runs on a core its final mask excludes. Select with one affinity snapshot, then validate the claimed core against a fresh snapshot and retry if it is excluded.

**L1**: The mask saved before the search is separate from the mask used to choose a core. A taker can save mask 1, choose core 1 while the mask is 2, then claim it after the mask returns to 1. Both setters can see no held core, and the final comparison sees 1 on both sides, so the thread runs on a core its final mask excludes. Select with one affinity snapshot, then validate the claimed core against a fresh snapshot and retry if it is excluded.
@ -240,0 +307,4 @@
check(!h0.vc_kick && h0.vc_held == 1, "a kick with nobody queued is cleared at the checkpoint, and the core kept");
check(hos_vcore_away() == 1, "a holder gives its core up");
h0.vc_kick = 2; /* (a kick set on a thread that has just let its core go: cleared at its next take) */
hos_vcore_back();
Member

L10: The handoff tests only switch simulated threads once the waiter is asleep. They never queue a waiter between the fast taker’s two queue reads, race two claimants, or destroy a thread while a scanner still holds its record. The fixture could pass with the post-claim queue check or destruction barrier removed. Add controlled cases that exercise those boundaries and fail when the corresponding protection is removed.

**L10**: The handoff tests only switch simulated threads once the waiter is asleep. They never queue a waiter between the fast taker’s two queue reads, race two claimants, or destroy a thread while a scanner still holds its record. The fixture could pass with the post-claim queue check or destruction barrier removed. Add controlled cases that exercise those boundaries and fail when the corresponding protection is removed.
futondestroyer left a comment

Recommendation: Request changes. Fold the owner-slot padding into the virtual-core fast-path change after fixing that branch's affinity and synchronization issues. Address the owner scans on the locked path and measure the combined change in gameplay.

New finding. At host/hos_thread.c:2208, 2213 and 2218, the wait loop reads the owner before checking whether the waiter can use that core. With this layout, a waiter pinned to a single core can read all eight owner cache lines under vc_lock. It can do this again on each timed wake, even with HOS_VCORE_FAST unset. The equal-priority scan on main checks affinity before loading the owner. Check affinity before each of these loads and measure a route with queued core waits. The no-waiter benchmark never enters these scans.

Inherited blockers. The padding leaves the prerequisite's ownership and affinity protocol in place. The earlier review found that a fast take can miss an affinity update and race with scheduler metadata readers. I also confirmed that when a fast take chooses a core under a nonzero mask and a concurrent remask restores mask zero before the claim, the take can overwrite the old cached preference before its requested checkpoint checks it. It can then keep the newly chosen core even if the cached core was free. Validate affinity and the preferred-core selection before publishing the cache, and cover this interleaving with a focused check. The old test_slow_frames.py assertion is already stale on main because vc_release delegates to vc_release_locked. Update it for the new signature and verify attribution through both release paths. Existing exact-head review · Prerequisite

Does it help? The author reports a 74–89% reduction in median uncontended take-and-release time with the fast path enabled on an i7-9700. Across 15 interleaved Windows rounds, medians went from 218.5 to 56.0 ns at two threads, 436.3 to 59.0 ns at four and 633.7 to 67.2 ns at six, with disjoint ranges. The locked reference numbers came from the unpadded prerequisite with its switch unset. The benchmark arms leave the gameplay gain and the cost of the shipping path against main unproven. Compare current main with the corrected combined head at its shipping default. Compare the corrected, unpadded and padded fast paths with the switch enabled if attributing the gain to padding. PR measurements

Other systems and switches. This changes a host scheduler used on Windows, Linux and Steam Deck. Guest synchronization, thread joins and NVN waits give up and reacquire cores through it. The padding adds 448 bytes of static storage and changes the layout in both modes. The last commit adds no switch. The prerequisite registers HOS_VCORE_FAST and defaults it off. With the switch unset, the stack also introduces stronger atomics on the locked path.

Checked and fine. All seven production uses of the owner array still access the same core index and preserve the prerequisite's atomic operations and memory order. The extracted fixture checks the 64-byte stride and base address alignment. The padding leaves the core-selection rules and thread teardown protocol untouched.

Testing. The author reports both virtual-core fixtures and the switch table passing on an earlier Windows Clang rebase. The changed-file sweep reported 44 passes, 11 failures and four skips. The captured Forgejo description check passed and source checks were pending. Author gameplay, Linux host build and Tier 1 gameplay coverage are open. Use warmed, interleaved Market and busy outdoor runs, including a route with measurable core waits. Report average FPS, 1% lows, median and p99 frame times, and wait and escape diagnostics.

Overlap. Keep this padding with the corrected virtual-core fast path as one scheduler PR. Keep the separate serial-core spin experiment out of the comparison so its changes do not confound the result. Fast path · Serial-core spinning

Reviewed. Head 8f250090a5fcdb586f84e2a82bc4b73b68d87a7e against main 6e1521a70a32603ed60a8263e4072625885669b7 and the unpadded parent e6acd10c727c3fefbd3981129756c58bd3c005eb. Read all five changed files at the touched areas, both fixtures, and relevant wait, affinity, lifecycle and statistics callers. Used revision-matched local source maps and checked the findings in Git source. Source review only. Longshot guidance 6e1521a7, Tooling 0b0059ac.

**Recommendation: Request changes.** Fold the owner-slot padding into the virtual-core fast-path change after fixing that branch's affinity and synchronization issues. Address the owner scans on the locked path and measure the combined change in gameplay. **New finding.** At `host/hos_thread.c:2208`, `2213` and `2218`, the wait loop reads the owner before checking whether the waiter can use that core. With this layout, a waiter pinned to a single core can read all eight owner cache lines under `vc_lock`. It can do this again on each timed wake, even with `HOS_VCORE_FAST` unset. The equal-priority scan on main checks affinity before loading the owner. Check affinity before each of these loads and measure a route with queued core waits. The no-waiter benchmark never enters these scans. **Inherited blockers.** The padding leaves the prerequisite's ownership and affinity protocol in place. The earlier review found that a fast take can miss an affinity update and race with scheduler metadata readers. I also confirmed that when a fast take chooses a core under a nonzero mask and a concurrent remask restores mask zero before the claim, the take can overwrite the old cached preference before its requested checkpoint checks it. It can then keep the newly chosen core even if the cached core was free. Validate affinity and the preferred-core selection before publishing the cache, and cover this interleaving with a focused check. The old `test_slow_frames.py` assertion is already stale on main because `vc_release` delegates to `vc_release_locked`. Update it for the new signature and verify attribution through both release paths. [Existing exact-head review](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1973#issuecomment-62404) · [Prerequisite](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1972) **Does it help?** The author reports a 74–89% reduction in median uncontended take-and-release time with the fast path enabled on an i7-9700. Across 15 interleaved Windows rounds, medians went from 218.5 to 56.0 ns at two threads, 436.3 to 59.0 ns at four and 633.7 to 67.2 ns at six, with disjoint ranges. The locked reference numbers came from the unpadded prerequisite with its switch unset. The benchmark arms leave the gameplay gain and the cost of the shipping path against main unproven. Compare current main with the corrected combined head at its shipping default. Compare the corrected, unpadded and padded fast paths with the switch enabled if attributing the gain to padding. [PR measurements](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1973) **Other systems and switches.** This changes a host scheduler used on Windows, Linux and Steam Deck. Guest synchronization, thread joins and NVN waits give up and reacquire cores through it. The padding adds 448 bytes of static storage and changes the layout in both modes. The last commit adds no switch. The prerequisite registers `HOS_VCORE_FAST` and defaults it off. With the switch unset, the stack also introduces stronger atomics on the locked path. **Checked and fine.** All seven production uses of the owner array still access the same core index and preserve the prerequisite's atomic operations and memory order. The extracted fixture checks the 64-byte stride and base address alignment. The padding leaves the core-selection rules and thread teardown protocol untouched. **Testing.** The author reports both virtual-core fixtures and the switch table passing on an earlier Windows Clang rebase. The changed-file sweep reported 44 passes, 11 failures and four skips. The captured Forgejo description check passed and source checks were pending. Author gameplay, Linux host build and Tier 1 gameplay coverage are open. Use warmed, interleaved Market and busy outdoor runs, including a route with measurable core waits. Report average FPS, 1% lows, median and p99 frame times, and wait and escape diagnostics. **Overlap.** Keep this padding with the corrected virtual-core fast path as one scheduler PR. Keep the separate serial-core spin experiment out of the comparison so its changes do not confound the result. [Fast path](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1972) · [Serial-core spinning](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1974) **Reviewed.** Head `8f250090a5fcdb586f84e2a82bc4b73b68d87a7e` against main `6e1521a70a32603ed60a8263e4072625885669b7` and the unpadded parent `e6acd10c727c3fefbd3981129756c58bd3c005eb`. Read all five changed files at the touched areas, both fixtures, and relevant wait, affinity, lifecycle and statistics callers. Used revision-matched local source maps and checked the findings in Git source. Source review only. Longshot guidance `6e1521a7`, Tooling `0b0059ac`.
@ -2063,3 +2206,3 @@
HosThread *worst = NULL;
for (int k = 0; k < vc_cores(); k++) {
HosThread *h = vc_owner[k];
HosThread *h = vc_holder(k);
Member

Check the waiter's affinity before loading the owner here and in the equal-priority and starvation scans below. A waiter pinned to one core now reads up to eight separate cache lines under vc_lock and can repeat the sweep on each timed wake, even with HOS_VCORE_FAST unset. Include a route with actual queued core waits in the comparison. The reported no-waiter benchmark does not exercise these scans.

Check the waiter's affinity before loading the owner here and in the equal-priority and starvation scans below. A waiter pinned to one core now reads up to eight separate cache lines under vc_lock and can repeat the sweep on each timed wake, even with HOS_VCORE_FAST unset. Include a route with actual queued core waits in the comparison. The reported no-waiter benchmark does not exercise these scans.
Author
Contributor

Folded into #1972 as asked in 62914: its commit is 1cde9675 there.

Folded into #1972 as asked in [62914](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1973#issuecomment-62914): its commit is 1cde9675 there.
siantm closed this pull request 2026-11-21 04:24:17 +00:00
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 16s
Website / Website on Cloudflare (pull_request_target) Has been skipped
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
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 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!1973
No description provided.