WIP: feat(os): HOS_WAKE_LAT also counts the event sleepers that slept more than once #1967

Draft
siantm wants to merge 3 commits from siantm/Longshot:feat/wake-lat-resleeps into main
Contributor

Summary

HOS_WAKE_LAT=1 (a diagnostic, off) logs every 5 s, for each thread, how its event and queue waits were met: ready,
after spinning, after sleeping, and the signal-to-running latency of the sleepers. An event waiter that wakes to a clear
event (a signal another waiter took first, or a wake with no signal for it) goes back to sleep, and the line did not
show it. It now says how many of the sleepers slept more than once (the line's format in wake_lat_note):

hos_log("wake: %s: %lld ready, %lld after spinning, %lld after sleeping, %lld of them more than once (signal "
        "to running %.1f us average, %.0f us longest)", ...)

so a wake of every waiter that wakes threads for nothing shows. Those sleepers still count as sleepers, with their
latency as before. What the line counts (the comment above wake_lat_on and the switch's row in gpu/vk/switches.def
say the same):

  • only waits that completed (got the event or a message): an event waiter that sleeps again and then times out counts
    in no bucket, however often it slept;
  • "after sleeping" and the latency are the thread's event and message queue waits together, so the repeat count is not
    a fraction of event sleepers alone;
  • "of them more than once" is event waits only; a queue receive that sleeps again is a plain sleeper;
  • a thread's line is logged only when it has more than 100 sleepers in the 5 s.

event_wait counts its sleeps in one state saturated at 2 (0 never slept, 1 slept, 2 slept again), in place of the
slept flag: bounded, as an untimed waiter can lose an auto-clear signal to other waiters without end. The table's rows
are keyed by the thread's id and keep a copy of its name (hos_thread_name_copy, host/hos_thread.c), taken under the
lock hos_thread_set_name now writes the name under: a thread that ends before the report (its HosThread freed or
reused) is printed by its own name, and another thread never merges into its row. Main's table kept the name pointer;
that is fixed here too, as this line extends it. Without the switch nothing changes in what the game does or logs.

From 78c83308 on exp/x86-asm-sync.

Read first: wake_lat_note and event_wait (its naps) in host/nn_os_sync.c; tests/test_wake_lat.py.

Testing

Tested: Windows 11, i7-9700, RTX 4060 (NVIDIA 610.88), llvm-mingw clang 23.1.5; game-free checks only. This change
has not run in the game on this PC yet (the run with HOS_WAKE_LAT=1: Still to test). Each check ran in a hidden console
of its own, in one job of the PC's job queue (fb3-1967-1), on this branch rebased onto main @ f1f2dc5b (head
4d2ebc2a):

  • python -I -B tests/test_wake_lat.py (new, 8f465100): passes at the head, three runs (with --cxx llvm-mingw clang++
    and with the compiler found from LONGSHOT_MINGW): Again 102 after sleeping, 101 of them more than once; Once 101, 0;
    TimedOut 101, 0 (its timed-out wait in no bucket); Queue 102, 1; Reused 101, 0; "wake lat: ok". At 8f465100, without
    the fix, it fails: the ended thread's row merges into the thread that reused its HosThread, under the new name
    ("Reused: ... 203 after sleeping, 101 of them more than once").
  • python -I -B tests/test_event_handoff.py: passes.
  • python -I -B tests/test_multiwait_wake.py: passes (head 4d2ebc2a's code before the fixture's last change, the same
    source).
  • python -I -B tests/run_all.py --strict --changed origin/main (5 files changed, 85 checks read them; 8 at once): 69
    passed, 16 failed, 4 skipped. 13 of the 16 failing checks (test_crash_dialog.py, test_crash_record.py,
    test_dev_ab.py, test_dev_packs.py, test_frame_overlap.py, test_host_guest_writes.py, test_libc_hooks.py,
    test_linux_pressure.py, test_mods_list.py, test_profiling_mode.py, test_slow_frames.py,
    test_vcore_escape.py, test_vcore_mask0.py) fail on main @ f1f2dc5b too, each run by name in the same queue's
    jobs. The other three (test_present_queue_default, test_target_reuse_memory, test_vk_occlusion_queries) compiled
    nothing in that run nor in the run on main (no Vulkan headers on the job's path: "not found: vulkan_headers
    (--strict)"). Rerun with the headers (job fb3-vk-1, RX_CPM set) at the head 4d2ebc2a and on main @ f1f2dc5b, each
    fails at both with the same first error: test_present_queue_default "srccut: '{TAB_DEBUG, "Present queue",
    &opts.present_queue, ...' is not in gpu/vk/vk_menu.cpp"; test_target_reuse_memory 2 of its 8 tests
    ("'vmaGetAllocationInfo2' unexpectedly found" in the VMA source, and its fixture's "use of undeclared identifier
    'destroy_image_later'"); test_vk_occlusion_queries "the ring fixture did not compile" ("no member named 'policy'").
    None fails on this branch alone.

Still to test:

  • Windows 11, this PC (i7-9700, RTX 4060 (NVIDIA 610.88)): Castle Town's market, 60 s, with HOS_WAKE_LAT=1, expecting
    the wake: lines with their "of them more than once" count, at most the "after sleeping" count (by hand)
  • Linux: build the host and start the game with HOS_WAKE_LAT=1, expecting the same wake: lines (by hand)

Measurements

Nothing to measure in play: it changes a diagnostic's log line, off by default (HOS_WAKE_LAT keeps its default); off, an event wait that sleeps updates one local state (the slept flag it replaces) per sleep.

Risks

Only the diagnostic's log line changes, and only with HOS_WAKE_LAT set; a script that reads the old line by its exact
text would need the new field. Off, an event wait that sleeps counts its sleeps in a local state of three values.
hos_thread_set_name now takes a lock around its write of the name (a guest SetThreadName, rare). #2020 fixes the
same rename race for every name reader another way (a thread's names are kept, never written over, and published
with one atomic store), and conflicts with this PR in host/hos_thread.c and host/hos.h: proposed order #2020
first, then this PR rebased onto it without its lock (hos_thread_name_copy then copies the kept name). No new switch: a
revert is enough. Players notice nothing: the switch is not set for them.

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 `HOS_WAKE_LAT=1` (a diagnostic, off) logs every 5 s, for each thread, how its event and queue waits were met: ready, after spinning, after sleeping, and the signal-to-running latency of the sleepers. An event waiter that wakes to a clear event (a signal another waiter took first, or a wake with no signal for it) goes back to sleep, and the line did not show it. It now says how many of the sleepers slept more than once (the line's format in `wake_lat_note`): ``` hos_log("wake: %s: %lld ready, %lld after spinning, %lld after sleeping, %lld of them more than once (signal " "to running %.1f us average, %.0f us longest)", ...) ``` so a wake of every waiter that wakes threads for nothing shows. Those sleepers still count as sleepers, with their latency as before. What the line counts (the comment above `wake_lat_on` and the switch's row in `gpu/vk/switches.def` say the same): - only waits that completed (got the event or a message): an event waiter that sleeps again and then times out counts in no bucket, however often it slept; - "after sleeping" and the latency are the thread's event and message queue waits together, so the repeat count is not a fraction of event sleepers alone; - "of them more than once" is event waits only; a queue receive that sleeps again is a plain sleeper; - a thread's line is logged only when it has more than 100 sleepers in the 5 s. `event_wait` counts its sleeps in one state saturated at 2 (0 never slept, 1 slept, 2 slept again), in place of the `slept` flag: bounded, as an untimed waiter can lose an auto-clear signal to other waiters without end. The table's rows are keyed by the thread's id and keep a copy of its name (`hos_thread_name_copy`, `host/hos_thread.c`), taken under the lock `hos_thread_set_name` now writes the name under: a thread that ends before the report (its `HosThread` freed or reused) is printed by its own name, and another thread never merges into its row. Main's table kept the name pointer; that is fixed here too, as this line extends it. Without the switch nothing changes in what the game does or logs. From 78c83308 on `exp/x86-asm-sync`. Read first: `wake_lat_note` and `event_wait` (its `naps`) in `host/nn_os_sync.c`; `tests/test_wake_lat.py`. ## Testing **Tested:** Windows 11, i7-9700, RTX 4060 (NVIDIA 610.88), llvm-mingw clang 23.1.5; game-free checks only. This change has not run in the game on this PC yet (the run with `HOS_WAKE_LAT=1`: Still to test). Each check ran in a hidden console of its own, in one job of the PC's job queue (fb3-1967-1), on this branch rebased onto `main` @ f1f2dc5b (head 4d2ebc2a): - `python -I -B tests/test_wake_lat.py` (new, 8f465100): passes at the head, three runs (with `--cxx` llvm-mingw clang++ and with the compiler found from `LONGSHOT_MINGW`): Again 102 after sleeping, 101 of them more than once; Once 101, 0; TimedOut 101, 0 (its timed-out wait in no bucket); Queue 102, 1; Reused 101, 0; "wake lat: ok". At 8f465100, without the fix, it fails: the ended thread's row merges into the thread that reused its `HosThread`, under the new name ("Reused: ... 203 after sleeping, 101 of them more than once"). - `python -I -B tests/test_event_handoff.py`: passes. - `python -I -B tests/test_multiwait_wake.py`: passes (head 4d2ebc2a's code before the fixture's last change, the same source). - `python -I -B tests/run_all.py --strict --changed origin/main` (5 files changed, 85 checks read them; 8 at once): 69 passed, 16 failed, 4 skipped. 13 of the 16 failing checks (`test_crash_dialog.py`, `test_crash_record.py`, `test_dev_ab.py`, `test_dev_packs.py`, `test_frame_overlap.py`, `test_host_guest_writes.py`, `test_libc_hooks.py`, `test_linux_pressure.py`, `test_mods_list.py`, `test_profiling_mode.py`, `test_slow_frames.py`, `test_vcore_escape.py`, `test_vcore_mask0.py`) fail on `main` @ f1f2dc5b too, each run by name in the same queue's jobs. The other three (`test_present_queue_default`, `test_target_reuse_memory`, `test_vk_occlusion_queries`) compiled nothing in that run nor in the run on `main` (no Vulkan headers on the job's path: "not found: vulkan_headers (--strict)"). Rerun with the headers (job fb3-vk-1, `RX_CPM` set) at the head 4d2ebc2a and on `main` @ f1f2dc5b, each fails at both with the same first error: `test_present_queue_default` "srccut: '{TAB_DEBUG, "Present queue", &opts.present_queue, ...' is not in gpu/vk/vk_menu.cpp"; `test_target_reuse_memory` 2 of its 8 tests ("'vmaGetAllocationInfo2' unexpectedly found" in the VMA source, and its fixture's "use of undeclared identifier 'destroy_image_later'"); `test_vk_occlusion_queries` "the ring fixture did not compile" ("no member named 'policy'"). None fails on this branch alone. **Still to test:** - Windows 11, this PC (i7-9700, RTX 4060 (NVIDIA 610.88)): Castle Town's market, 60 s, with `HOS_WAKE_LAT=1`, expecting the `wake:` lines with their "of them more than once" count, at most the "after sleeping" count (by hand) - Linux: build the host and start the game with `HOS_WAKE_LAT=1`, expecting the same `wake:` lines (by hand) ## Measurements Nothing to measure in play: it changes a diagnostic's log line, off by default (`HOS_WAKE_LAT` keeps its default); off, an event wait that sleeps updates one local state (the slept flag it replaces) per sleep. ## Risks Only the diagnostic's log line changes, and only with `HOS_WAKE_LAT` set; a script that reads the old line by its exact text would need the new field. Off, an event wait that sleeps counts its sleeps in a local state of three values. `hos_thread_set_name` now takes a lock around its write of the name (a guest SetThreadName, rare). #2020 fixes the same rename race for every name reader another way (a thread's names are kept, never written over, and published with one atomic store), and conflicts with this PR in `host/hos_thread.c` and `host/hos.h`: proposed order #2020 first, then this PR rebased onto it without its lock (`hos_thread_name_copy` then copies the kept name). No new switch: a revert is enough. Players notice nothing: the switch is not set for them. ## Checklist ### Ready for review - [x] 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). - [x] 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.
feat(os): HOS_WAKE_LAT also counts the event sleepers that slept more than once
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 15s
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
10bf17beea
HOS_WAKE_LAT's line says, per thread, how its event and queue waits were met: ready, after spinning, after sleeping. An
event waiter that wakes to a clear event (a signal another waiter took first, or a wake with no signal) sleeps again;
the line now says how many of the sleepers did, so a wake-all that wakes threads for nothing shows. Nothing changes
without the switch.

From 78c83308 on exp/x86-asm-sync.

Assisted-by: Claude Code
Member

Possibly related, for context:

  • issue #1505 Every event, queue and semaphore signal locks and wakes all waiters, and takes a global lock while any thread waits in a multi-wait — Related host event-wakeup behavior and measurements
  • issue #1506 The game's 20 microsecond poll sleeps wake threads thousands of times a second, and the host cannot tell idle polls from needed ones — Uses HOS_WAKE_LAT in its poll-sleep investigation
Possibly related, for context: - issue #1505 Every event, queue and semaphore signal locks and wakes all waiters, and takes a global lock while any thread waits in a multi-wait — Related host event-wakeup behavior and measurements - issue #1506 The game's 20 microsecond poll sleeps wake threads thousands of times a second, and the host cannot tell idle polls from needed ones — Uses HOS_WAKE_LAT in its poll-sleep investigation
BeanBot left a comment

Recommendation: Request changes. The new count can help diagnose event wakeups, but its signed sleep counter can overflow even with the diagnostic off, and the report can read a destroyed thread’s name. The reported checks never verify a nonzero repeat-sleeper count.

With HOS_WAKE_LAT enabled, the log gains a count of completed event waits that slept again. Those waits still count once in the sleeper total and latency calculation. The change adds one counter per report slot and extra bookkeeping to event waits that sleep, including with the default settings.

@fix will do (6)

  1. L1 host/nn_os_sync.c:941: The signed naps counter increments without a bound, even with HOS_WAKE_LAT off. (more on the line)
  2. L2 host/nn_os_sync.c:886: The report table retains a pointer into HosThread. (more on the line)
  3. L3 (minor) host/nn_os_sync.c:947: The existing event handoff test disables the diagnostic and the multi-wait fixture discards its samples. (more on the line)
  4. L4 (minor) gpu/vk/switches.def:228: The row and PR summary promise a five-second per-thread report, but the logger only emits a row when that thread completes more than 100 sleeping waits in the interval. (more on the line)
  5. L5 (its part an edit can do) host/nn_os_sync.c:947: Use one bounded sleep state in place of two variables to shrink the default-path bookkeeping. Add a controlled event fixture to verify a nonzero count when the game workload cannot reliably produce one.
  6. L6 (minor): The PR ticks the source-check update box, but the diff changes only the host source and switch table. Update the box to match the final diff. The reported --changed run is the targeted check, so record the full mise run test and lint results under Testing before marking the PR ready.

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

  • L5 (minor) host/nn_os_sync.c:947: The planned smoke runs would pass if the new field always printed zero. (more on the line)

Checks: Still running: PR description / Description follows the template (pull_request_target), 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).

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

Does it help: Unproven. The PR reports 31 passes, seven failures also seen on main, and three skips on Windows at the earlier rebased head bdeabe83. No run shows a nonzero repeat-sleeper count, and no frame-time comparison measures the cost with the diagnostic off.

Other systems: Normal, light, and system event waits share the changed loop, so the extra bookkeeping can reach frame workers and device waits on Windows and Linux, including Steam Deck. Queue waits keep their existing classification and latency path but gain the field in their shared report. Multi-wait, timer, and semaphore waits stay outside the new count. No in-game evidence covers the affected Tier 1 systems.

Switches: HOS_WAKE_LAT remains a developer diagnostic, off by default on all platforms. That is the right default for periodic logging. The switch table documents the new field but omits its reporting limits, and the default-off cost remains unmeasured.

Reviewed: 10bf17beea against 6e1521a70a: Read host/nn_os_sync.c in full, the complete diff and commit message, AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, and the Forgejo template. Read the changed switch row and its neighboring rows, and inspected the switch consumer, thread naming and destruction, host wait implementations, and event test fixtures. Skimmed the rest of the switch table and the reported Windows results. docs/review-checklist.md and the sibling Tooling checkout were absent. The PR supplied no run logs, comments, or earlier reviews.; nothing run (a code review).

Checked and fine:

  • The new table counters and reporting interval are protected by the same lock. The switch cache is thread-local and the added wait bookkeeping allocates nothing.
  • The three existing wait classifications remain reachable, and the repeat classification contributes exactly once to both the sleeper total and latency calculation.
  • The format arguments match their conversions and fit the existing log buffer with the bounded host thread name.
  • The diff stays on one topic, uses a Conventional Commit title after Forgejo’s WIP prefix, and includes the required AI assistance trailer.
  • The diff contains no game-derived output, third-party or generated file changes, shader edits, renderer API changes, or executable tooling changes.

Testing: Read-only review. The author reports the targeted Windows checks on bdeabe83. The seven named failures also occurred on the earlier base. The author reports an unchanged rebase to 10bf17be. Head CI is pending, and the Windows and Linux in-game runs are outstanding.

Overlaps and merge order: No overlapping pull request was visible in the supplied material. The PR names exp/x86-asm-sync as the source of the change, and the source commit is absent from the checkout.


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 new count can help diagnose event wakeups, but its signed sleep counter can overflow even with the diagnostic off, and the report can read a destroyed thread’s name. The reported checks never verify a nonzero repeat-sleeper count. With HOS_WAKE_LAT enabled, the log gains a count of completed event waits that slept again. Those waits still count once in the sleeper total and latency calculation. The change adds one counter per report slot and extra bookkeeping to event waits that sleep, including with the default settings. **`@fix` will do (6)** 1. **L1** `host/nn_os_sync.c:941`: The signed naps counter increments without a bound, even with HOS_WAKE_LAT off. (more on the line) 2. **L2** `host/nn_os_sync.c:886`: The report table retains a pointer into HosThread. (more on the line) 3. **L3** (minor) `host/nn_os_sync.c:947`: The existing event handoff test disables the diagnostic and the multi-wait fixture discards its samples. (more on the line) 4. **L4** (minor) `gpu/vk/switches.def:228`: The row and PR summary promise a five-second per-thread report, but the logger only emits a row when that thread completes more than 100 sleeping waits in the interval. (more on the line) 5. **L5** (its part an edit can do) `host/nn_os_sync.c:947`: Use one bounded sleep state in place of two variables to shrink the default-path bookkeeping. Add a controlled event fixture to verify a nonzero count when the game workload cannot reliably produce one. 6. **L6** (minor): The PR ticks the source-check update box, but the diff changes only the host source and switch table. Update the box to match the final diff. The reported --changed run is the targeted check, so record the full mise run test and lint results under Testing before marking the PR ready. **For the author (1)** (a run, a measurement or a decision) - **L5** (minor) `host/nn_os_sync.c:947`: The planned smoke runs would pass if the new field always printed zero. (more on the line) **Checks:** Still running: `PR description / Description follows the template (pull_request_target)`, `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)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven. The PR reports 31 passes, seven failures also seen on main, and three skips on Windows at the earlier rebased head bdeabe83. No run shows a nonzero repeat-sleeper count, and no frame-time comparison measures the cost with the diagnostic off. **Other systems:** Normal, light, and system event waits share the changed loop, so the extra bookkeeping can reach frame workers and device waits on Windows and Linux, including Steam Deck. Queue waits keep their existing classification and latency path but gain the field in their shared report. Multi-wait, timer, and semaphore waits stay outside the new count. No in-game evidence covers the affected Tier 1 systems. **Switches:** HOS_WAKE_LAT remains a developer diagnostic, off by default on all platforms. That is the right default for periodic logging. The switch table documents the new field but omits its reporting limits, and the default-off cost remains unmeasured. **Reviewed:** 10bf17beea8c against 6e1521a70a32: Read host/nn_os_sync.c in full, the complete diff and commit message, AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, and the Forgejo template. Read the changed switch row and its neighboring rows, and inspected the switch consumer, thread naming and destruction, host wait implementations, and event test fixtures. Skimmed the rest of the switch table and the reported Windows results. docs/review-checklist.md and the sibling Tooling checkout were absent. The PR supplied no run logs, comments, or earlier reviews.; nothing run (a code review). **Checked and fine:** - The new table counters and reporting interval are protected by the same lock. The switch cache is thread-local and the added wait bookkeeping allocates nothing. - The three existing wait classifications remain reachable, and the repeat classification contributes exactly once to both the sleeper total and latency calculation. - The format arguments match their conversions and fit the existing log buffer with the bounded host thread name. - The diff stays on one topic, uses a Conventional Commit title after Forgejo’s WIP prefix, and includes the required AI assistance trailer. - The diff contains no game-derived output, third-party or generated file changes, shader edits, renderer API changes, or executable tooling changes. **Testing:** Read-only review. The author reports the targeted Windows checks on bdeabe83. The seven named failures also occurred on the earlier base. The author reports an unchanged rebase to 10bf17be. Head CI is pending, and the Windows and Linux in-game runs are outstanding. **Overlaps and merge order:** No overlapping pull request was visible in the supplied material. The PR names exp/x86-asm-sync as the source of the change, and the source commit is absent from the checkout. </details> --- <sub>Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.</sub>
@ -226,3 +226,3 @@
SW(HOS_WAIT_WHO, diag, string, "off", "For the named thread, logs the events it waits on and who signals them.")
SW(HOS_WAIT_WHO_LR, diag, string, "every caller", "Narrows HOS_WAIT_WHO to waits from one guest caller (hex return address).")
SW(HOS_WAKE_LAT, diag, bool, "off", "Every 5 s, per thread: how event and queue waits were met and the signal-to-running latency.")
SW(HOS_WAKE_LAT, diag, bool, "off", "Every 5 s, per thread: how event and queue waits were met (ready, after spinning, after sleeping, and how many event sleepers woke to a clear event and slept again) and the signal-to-running latency.")
Member

L4 (minor): The row and PR summary promise a five-second per-thread report, but the logger only emits a row when that thread completes more than 100 sleeping waits in the interval. A worker can sleep again and complete ten waits without a line, and a timed wait that expires contributes nothing. Document the threshold and say that the repeat count covers successful event waits.

**L4** (minor): The row and PR summary promise a five-second per-thread report, but the logger only emits a row when that thread completes more than 100 sleeping waits in the interval. A worker can sleep again and complete ten waits without a line, and a timed wait that expires contributes nothing. Document the threshold and say that the repeat count covers successful event waits.
@ -885,2 +884,3 @@
static void wake_lat_note(int how, int64_t lat_ns) { /* how: 0 ready, 1 spun, 2 slept, 3 slept more than once */
static SRWLOCK lk = SRWLOCK_INIT;
static struct { const char *thread; int64_t n[3], lat, max; } tab[32];
static struct { const char *thread; int64_t n[4], lat, max; } tab[32];
Member

L2: The report table retains a pointer into HosThread. A worker can record 101 sleeps, then be joined and freed before another thread prints its row. The %s then reads freed memory, and allocator reuse can also merge two workers' counts. SetThreadName can also rewrite that buffer while it is being read. This is already present on main in the logger being extended here. Key rows by stable thread ID and keep an owned name snapshot taken under synchronization shared with renames.

**L2**: The report table retains a pointer into HosThread. A worker can record 101 sleeps, then be joined and freed before another thread prints its row. The %s then reads freed memory, and allocator reuse can also merge two workers' counts. SetThreadName can also rewrite that buffer while it is being read. This is already present on main in the logger being extended here. Key rows by stable thread ID and keep an owned name snapshot taken under synchronization shared with renames.
@ -937,3 +939,3 @@
hos_cv_sleep(&e->cv, &e->lk, INFINITE);
}
slept = 1;
slept = 1, naps++;
Member

L1: The signed naps counter increments without a bound, even with HOS_WAKE_LAT off. An untimed waiter that repeatedly loses an auto-clear signal can stay in the loop indefinitely. At 10,000 retries per second it would reach signed overflow in about 60 hours. Track three states instead, saturate at two sleeps, and use that state in place of the separate slept flag.

**L1**: The signed naps counter increments without a bound, even with HOS_WAKE_LAT off. An untimed waiter that repeatedly loses an auto-clear signal can stay in the loop indefinitely. At 10,000 retries per second it would reach signed overflow in about 60 hours. Track three states instead, saturate at two sleeps, and use that state in place of the separate slept flag.
@ -943,3 +945,3 @@
ReleaseSRWLockExclusive(&e->lk);
}
if (got && wake_lat_on()) wake_lat_note(slept ? 2 : 1, slept ? hos_now_ns() - signaled_at : 0);
if (got && wake_lat_on()) wake_lat_note(naps > 1 ? 3 : slept ? 2 : 1, slept ? hos_now_ns() - signaled_at : 0);
Member

L3 (minor): The existing event handoff test disables the diagnostic and the multi-wait fixture discards its samples. Reverting the repeat classification or omitting its contribution to the sleeper total would escape both. Extend the event fixture with a controlled clear wake followed by a successful signal, and check the reported repeat subset, total sleepers, and latency. Include a single sleep as a control and use the existing compiler selection.

**L3** (minor): The existing event handoff test disables the diagnostic and the multi-wait fixture discards its samples. Reverting the repeat classification or omitting its contribution to the sleeper total would escape both. Extend the event fixture with a controlled clear wake followed by a successful signal, and check the reported repeat subset, total sleepers, and latency. Include a single sleep as a control and use the existing compiler selection.
Member

L5 (minor): The planned smoke runs would pass if the new field always printed zero. On the Windows and Linux head builds, exercise a workload that produces a repeat sleeper and verify a nonzero count within the sleeper total. Include the affected Tier 1 systems in the run record and a matched, interleaved frame-time comparison with main at the default off setting. The PR opened before the required author-side game run.

**L5** (minor): The planned smoke runs would pass if the new field always printed zero. On the Windows and Linux head builds, exercise a workload that produces a repeat sleeper and verify a nonzero count within the sleeper total. Include the affected Tier 1 systems in the run record and a matched, interleaved frame-time comparison with main at the default off setting. The PR opened before the required author-side game run.
futondestroyer left a comment

Recommendation: Request changes. A bounded sleep state can make the diagnostic useful without introducing a signed counter that can overflow even when the switch is off. The retained thread-name pointer also needs a lifetime-safe representation before this diagnostic is used to compare wake paths. Existing exact-head review

Reviewed. Head 10bf17beea8c07c44387abfd90f3f1a5c2a6acc4 against merge base 6e1521a70a32603ed60a8263e4072625885669b7. Read both changed files, the event wait, signal, timeout and queue-receive callers, and the fixtures that cut those paths. Validated both source-only Graphify maps. No code run.

Checked and fine. The repeat bucket counts once in the total sleeper bucket and contributes one latency sample. The existing predicate, try-only path and absolute timeout handling stay in place. The default for HOS_WAKE_LAT stays off.

Blocking. A waiter can repeatedly wake without acquiring the event over an unbounded wait. The new signed increment at host/nn_os_sync.c:941 runs on the disabled path as well. Use one state saturated after the second completed sleep. The same report's existing borrowed thread-name pointer can outlive its owner. Use a stable ID and a lifetime-safe snapshot. Both lines are already discussed in the linked review.

Measurement interpretation. The added field counts completed event waits that returned from a wait more than once. A waiter that re-sleeps and eventually times out contributes nothing. The aggregate sleeper denominator is also shared with queue receivers. Document those boundaries before using the value to infer event fairness or report a repeat-wake fraction. A small fixture should drive a clear wake followed by another sleep, plus a timeout control and a queue sample, to check what lands in each bucket.

Testing. The author reports targeted Windows game-free results with baseline failures at earlier revisions. The PR has no direct assertion for the new field, no Windows or Linux gameplay confirmation, and pending or blocked check contexts. Verify Windows and Linux diagnostic output on the corrected head. This is diagnostic evidence, so a frame-rate farm trial now would add little.

Overlap and merge order. This touches the same event_wait and wake_lat_note paths as 1970 and 1971. Settle the metric and its test first, then preserve it when the park and handoff track is rebased.

**Recommendation: Request changes.** A bounded sleep state can make the diagnostic useful without introducing a signed counter that can overflow even when the switch is off. The retained thread-name pointer also needs a lifetime-safe representation before this diagnostic is used to compare wake paths. [Existing exact-head review](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1967#issuecomment-62279) **Reviewed.** Head `10bf17beea8c07c44387abfd90f3f1a5c2a6acc4` against merge base `6e1521a70a32603ed60a8263e4072625885669b7`. Read both changed files, the event wait, signal, timeout and queue-receive callers, and the fixtures that cut those paths. Validated both source-only Graphify maps. No code run. **Checked and fine.** The repeat bucket counts once in the total sleeper bucket and contributes one latency sample. The existing predicate, try-only path and absolute timeout handling stay in place. The default for `HOS_WAKE_LAT` stays off. **Blocking.** A waiter can repeatedly wake without acquiring the event over an unbounded wait. The new signed increment at `host/nn_os_sync.c:941` runs on the disabled path as well. Use one state saturated after the second completed sleep. The same report's existing borrowed thread-name pointer can outlive its owner. Use a stable ID and a lifetime-safe snapshot. Both lines are already discussed in the linked review. **Measurement interpretation.** The added field counts completed event waits that returned from a wait more than once. A waiter that re-sleeps and eventually times out contributes nothing. The aggregate sleeper denominator is also shared with queue receivers. Document those boundaries before using the value to infer event fairness or report a repeat-wake fraction. A small fixture should drive a clear wake followed by another sleep, plus a timeout control and a queue sample, to check what lands in each bucket. **Testing.** The author reports targeted Windows game-free results with baseline failures at earlier revisions. The PR has no direct assertion for the new field, no Windows or Linux gameplay confirmation, and pending or blocked check contexts. Verify Windows and Linux diagnostic output on the corrected head. This is diagnostic evidence, so a frame-rate farm trial now would add little. **Overlap and merge order.** This touches the same `event_wait` and `wake_lat_note` paths as [1970](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1970) and [1971](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1971). Settle the metric and its test first, then preserve it when the park and handoff track is rebased.
@ -943,3 +945,3 @@
ReleaseSRWLockExclusive(&e->lk);
}
if (got && wake_lat_on()) wake_lat_note(slept ? 2 : 1, slept ? hos_now_ns() - signaled_at : 0);
if (got && wake_lat_on()) wake_lat_note(naps > 1 ? 3 : slept ? 2 : 1, slept ? hos_now_ns() - signaled_at : 0);
Member

Please document that this samples only completed event waits. An event waiter can re-sleep and then time out without appearing here, while the sleeper denominator in wake_lat_note also includes queue waits. Those distinctions matter when comparing event fairness across wake implementations.

Please document that this samples only completed event waits. An event waiter can re-sleep and then time out without appearing here, while the sleeper denominator in wake_lat_note also includes queue waits. Those distinctions matter when comparing event fairness across wake implementations.
siantm force-pushed feat/wake-lat-resleeps from 10bf17beea
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 15s
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
to 4d2ebc2ae8
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
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
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 22s
beanstalk/approval approved by futondestroyer (reviewed)
beanstalk/windows 0/1 pass, 2 running, 0 queued
beanstalk/linux 0/1 pass, 2 running, 0 queued
2026-11-21 04:44:19 +00:00
Compare
Author
Contributor

Pushed 4d2ebc2a (rebased onto main @ f1f2dc5b; the PR's commit unchanged): event_wait's sleep count is one bounded state, HOS_WAKE_LAT's rows are keyed by thread id with an owned copy of the name, the comment, switch row and Summary say what the line counts (completed waits only; event and queue sleepers together), and the new tests/test_wake_lat.py checks each bucket. Testing lists this head's checks.

Pushed 4d2ebc2a (rebased onto `main` @ f1f2dc5b; the PR's commit unchanged): `event_wait`'s sleep count is one bounded state, `HOS_WAKE_LAT`'s rows are keyed by thread id with an owned copy of the name, the comment, switch row and Summary say what the line counts (completed waits only; event and queue sleepers together), and the new `tests/test_wake_lat.py` checks each bucket. Testing lists this head's checks.
Author
Contributor

@futondestroyer, on your review and inline, head 4d2ebc2a (rebased onto main @ f1f2dc5b; the PR's own commit unchanged, git range-diff "="):

  • Unbounded signed counter (host/nn_os_sync.c:941): fixed in 4d2ebc2a. event_wait keeps one state saturated at 2 (naps += naps < 2: 0 never slept, 1 slept, 2 slept again) in place of both slept and the counter, so nothing grows however often an untimed waiter loses the signal. Bounded by construction; no test drives 2^31 sleeps.
  • Borrowed thread-name pointer: fixed in 4d2ebc2a. Rows are keyed by hos_thread_id and keep a 48-byte copy of the name, taken at the thread's first note of the 5 s with the new hos_thread_name_copy under the lock hos_thread_set_name now writes the name under (the same idea as 18e90465: copy while the owner cannot change or end it; here the caller is the thread itself). tests/test_wake_lat.py (8f465100) ends a thread, reuses its HosThread renamed for another thread and checks two rows with their own names; at 8f465100 without the fix it fails: the ended thread's 102 sleepers merge into the new one's row under the new name (203).
  • What the field counts (inline 62900): the comment above wake_lat_on, the switch row and the description now say it: only completed waits (an event waiter that sleeps again and then times out counts in no bucket), "after sleeping" and the latency are the thread's event and queue waits together, "of them more than once" is event waits only, a line needs more than 100 sleepers. The fixture runs nn_os_sync.c's own event_wait, queue_get and wake_lat_note on real threads: 101 clear wakes then another sleep each (102 sleepers, 101 more than once), 101 single sleeps (101, 0), a timed wait woken to a clear event that sleeps again and runs out plus 101 single sleeps (101, 0: the timeout counts nothing), and 101 queue receives that slept plus one event re-sleep on one thread (102, 1: the shared denominator).
  • Windows and Linux diagnostic output on the corrected head: pending, asked of the game runs on this PC (Windows) and Linux; no result yet.

Checks: tests/test_wake_lat.py, test_event_handoff.py, test_multiwait_wake.py pass; run_all.py --strict --changed origin/main: 69 passed, 16 failed, 4 skipped, all 16 failing on main @ f1f2dc5b too (Testing in the description).

@futondestroyer, on your [review](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1967#issuecomment-62901) and [inline](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1967#issuecomment-62900), head 4d2ebc2a (rebased onto `main` @ f1f2dc5b; the PR's own commit unchanged, `git range-diff` "="): - **Unbounded signed counter** (`host/nn_os_sync.c:941`): fixed in 4d2ebc2a. `event_wait` keeps one state saturated at 2 (`naps += naps < 2`: 0 never slept, 1 slept, 2 slept again) in place of both `slept` and the counter, so nothing grows however often an untimed waiter loses the signal. Bounded by construction; no test drives 2^31 sleeps. - **Borrowed thread-name pointer**: fixed in 4d2ebc2a. Rows are keyed by `hos_thread_id` and keep a 48-byte copy of the name, taken at the thread's first note of the 5 s with the new `hos_thread_name_copy` under the lock `hos_thread_set_name` now writes the name under (the same idea as 18e90465: copy while the owner cannot change or end it; here the caller is the thread itself). `tests/test_wake_lat.py` (8f465100) ends a thread, reuses its `HosThread` renamed for another thread and checks two rows with their own names; at 8f465100 without the fix it fails: the ended thread's 102 sleepers merge into the new one's row under the new name (203). - **What the field counts** (inline 62900): the comment above `wake_lat_on`, the switch row and the description now say it: only completed waits (an event waiter that sleeps again and then times out counts in no bucket), "after sleeping" and the latency are the thread's event and queue waits together, "of them more than once" is event waits only, a line needs more than 100 sleepers. The fixture runs nn_os_sync.c's own `event_wait`, `queue_get` and `wake_lat_note` on real threads: 101 clear wakes then another sleep each (102 sleepers, 101 more than once), 101 single sleeps (101, 0), a timed wait woken to a clear event that sleeps again and runs out plus 101 single sleeps (101, 0: the timeout counts nothing), and 101 queue receives that slept plus one event re-sleep on one thread (102, 1: the shared denominator). - **Windows and Linux diagnostic output on the corrected head**: pending, asked of the game runs on this PC (Windows) and Linux; no result yet. Checks: `tests/test_wake_lat.py`, `test_event_handoff.py`, `test_multiwait_wake.py` pass; `run_all.py --strict --changed origin/main`: 69 passed, 16 failed, 4 skipped, all 16 failing on `main` @ f1f2dc5b too (Testing in the description).
Author
Contributor

BeanBot's review, head 4d2ebc2a:

  • L1 (62274): one state saturated at 2 replaces the counter and slept (4d2ebc2a).
  • L2 (62275): rows by thread id with a name copy taken under the lock renames now take (4d2ebc2a; tests/test_wake_lat.py, failing at 8f465100).
  • L3 (62276): a new fixture, tests/test_wake_lat.py (8f465100), with the real wake_lat_note (the handoff test keeps its stub): clear wake then success, single-sleep control, timeout, queue; latency checked as 0 on the fixture's own clock. Compiler: --cxx, then CXX, then LONGSHOT_MINGW's clang++, then PATH.
  • L4 (62277): the row and comment name the 100-sleeper threshold and that only completed waits count.
  • L5 (62278): the bounded state is done and the fixture shows a nonzero count within the sleeper total; the Windows and Linux runs with a nonzero count are pending (game runs); a frame-time A/B with the switch off is not planned: the maintainer's review judges a farm trial of little use for a diagnostic.
  • L6: the source-check box now holds (a new check reads the changed source); mise run test in full has not run, so its box stays open.
BeanBot's [review](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1967#issuecomment-62279), head 4d2ebc2a: - L1 ([62274](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1967#issuecomment-62274)): one state saturated at 2 replaces the counter and `slept` (4d2ebc2a). - L2 ([62275](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1967#issuecomment-62275)): rows by thread id with a name copy taken under the lock renames now take (4d2ebc2a; `tests/test_wake_lat.py`, failing at 8f465100). - L3 ([62276](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1967#issuecomment-62276)): a new fixture, `tests/test_wake_lat.py` (8f465100), with the real wake_lat_note (the handoff test keeps its stub): clear wake then success, single-sleep control, timeout, queue; latency checked as 0 on the fixture's own clock. Compiler: `--cxx`, then `CXX`, then `LONGSHOT_MINGW`'s clang++, then PATH. - L4 ([62277](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1967#issuecomment-62277)): the row and comment name the 100-sleeper threshold and that only completed waits count. - L5 ([62278](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1967#issuecomment-62278)): the bounded state is done and the fixture shows a nonzero count within the sleeper total; the Windows and Linux runs with a nonzero count are pending (game runs); a frame-time A/B with the switch off is not planned: the maintainer's review judges a farm trial of little use for a diagnostic. - L6: the source-check box now holds (a new check reads the changed source); `mise run test` in full has not run, so its box stays open.
Author
Contributor

@Beanstalk This touches only the HOS_WAKE_LAT diagnostic (off unless set) in the guest event and queue waits (host/nn_os_sync.c): its wake log lines also say how many event sleepers slept more than once. Nothing is meant to get faster, so no frame-time comparison is asked. It has not run in the game on these PCs yet. Please start the game and play Castle Town Market for one minute with HOS_WAKE_LAT=1, on a Windows PC and on a Linux PC. No crash; the log must have the wake lines every 5 s with their "of them more than once" count.

@Beanstalk This touches only the HOS_WAKE_LAT diagnostic (off unless set) in the guest event and queue waits (host/nn_os_sync.c): its wake log lines also say how many event sleepers slept more than once. Nothing is meant to get faster, so no frame-time comparison is asked. It has not run in the game on these PCs yet. Please start the game and play Castle Town Market for one minute with HOS_WAKE_LAT=1, on a Windows PC and on a Linux PC. No crash; the log must have the wake lines every 5 s with their "of them more than once" count.
Member

@siantm only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@siantm only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Author
Contributor

Description: Risks names #2020 (the same rename race fixed for every reader) and the proposed landing order; no code change.

Description: Risks names #2020 (the same rename race fixed for every reader) and the proposed landing order; no code change.
Author
Contributor

The three renderer checks (test_present_queue_default, test_target_reuse_memory, test_vk_occlusion_queries) did not compile in the earlier run (no Vulkan headers on that job's path); rerun with them in job fb3-vk-1, at the head 4d2ebc2a and on main @ f1f2dc5b: all three fail at both with the same first error, so they fail on main too; Tested's sentence and counts corrected.

The three renderer checks (`test_present_queue_default`, `test_target_reuse_memory`, `test_vk_occlusion_queries`) did not compile in the earlier run (no Vulkan headers on that job's path); rerun with them in job fb3-vk-1, at the head 4d2ebc2a and on `main` @ f1f2dc5b: all three fail at both with the same first error, so they fail on `main` too; Tested's sentence and counts corrected.
futondestroyer left a comment

Recommendation: Wait for a Windows and Linux diagnostic smoke test. The saturating wait state and owned thread-name copy address the earlier source findings. The switch stays off by default.

For the pending Farm request, the reviewed pair predates the market-entrance repository save. Both revisions support kokiri-start and the control bridge's Market_Child teleport. Start from that save on both sides, wait for gameplay, use the teleport and verify arrival before the one-minute window. Check the new count in an eligible candidate row. Existing request

On a completed event wait the counter now stays at two after the second sleep. A timed-out wait contributes no sample. Queue waits remain in the total sleeper count and never enter the repeat-event bucket. The fixture compares those cases explicitly and reuses a thread record under a new ID. Host IDs are allocated by the shared 64-bit counter. The collector copies the current thread's name under the same lock the setter holds while writing it, so the logged row can safely outlive the thread.

The report is evaluated on a completed wait after five seconds have elapsed. It emits rows only for threads with more than 100 completed sleeping waits in the interval. A Market smoke should look for an eligible wake: row with the new count and record an interval without eligible rows as inconclusive. A zero repeat count is valid. This diagnostic adds no intended gameplay speedup. The author reports the focused Windows fixture passing on this head. Cross-host gameplay and CI are still outstanding. Author evidence · Existing Test Farm request

Recheck the fixture when rebasing onto main's later presentation wait change: the base here still has the full queue_get body where the fixture cuts it. Keep this bucket definition when reconciling the event handoff and park series. Presentation wait change

Reviewed. 4d2ebc2ae833fac60c9f32244eb872fdddb1b689 against actual merge base f1f2dc5bd2821cef061798ba40a043d281ac1707. Reviewed the five changed files, the event and queue callers and the thread ID and name ownership. Both revision-matched Graphify maps verified and queried. Source only.

**Recommendation: Wait for a Windows and Linux diagnostic smoke test.** The saturating wait state and owned thread-name copy address the earlier source findings. The switch stays off by default. For the pending Farm request, the reviewed pair predates the `market-entrance` repository save. Both revisions support `kokiri-start` and the control bridge's `Market_Child` teleport. Start from that save on both sides, wait for gameplay, use the teleport and verify arrival before the one-minute window. Check the new count in an eligible candidate row. [Existing request](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1967#issuecomment-63555) On a completed event wait the counter now stays at two after the second sleep. A timed-out wait contributes no sample. Queue waits remain in the total sleeper count and never enter the repeat-event bucket. The fixture compares those cases explicitly and reuses a thread record under a new ID. Host IDs are allocated by the shared 64-bit counter. The collector copies the current thread's name under the same lock the setter holds while writing it, so the logged row can safely outlive the thread. The report is evaluated on a completed wait after five seconds have elapsed. It emits rows only for threads with more than 100 completed sleeping waits in the interval. A Market smoke should look for an eligible `wake:` row with the new count and record an interval without eligible rows as inconclusive. A zero repeat count is valid. This diagnostic adds no intended gameplay speedup. The author reports the focused Windows fixture passing on this head. Cross-host gameplay and CI are still outstanding. [Author evidence](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1967#issuecomment-63553) · [Existing Test Farm request](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1967#issuecomment-63555) Recheck the fixture when rebasing onto main's later presentation wait change: the base here still has the full `queue_get` body where the fixture cuts it. Keep this bucket definition when reconciling the event handoff and park series. [Presentation wait change](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1859) **Reviewed.** `4d2ebc2ae833fac60c9f32244eb872fdddb1b689` against actual merge base `f1f2dc5bd2821cef061798ba40a043d281ac1707`. Reviewed the five changed files, the event and queue callers and the thread ID and name ownership. Both revision-matched Graphify maps verified and queried. Source only.
Member

Beanstalk test farm · 🔄 testing (0 of 2 reports so far)

Commit 4d2ebc2 · approved by futondestroyer (👍 on siantm's request) (reviewed) · dashboard

⚠️ Note: Rows are emitted only for threads with more than 100 completed sleeping waits, so no eligible row makes the expected-line check inconclusive.
⚠️ Note: The farm cannot verify the five-second cadence or compare the repeat count numerically with the sleeper count; the one-minute measurement is stationary after the movement step.

Started at 09:39 UTC.

Estimate: done in about 40 min, from the queue and the testers online now.

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

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

On one Windows PC and one Linux PC, the game will run with HOS_WAKE_LAT=1, teleport to Castle Town Market, move, and spend one minute there. The test checks for crashes and an eligible wake log row containing the new numeric count; a missing eligible row is inconclusive. Each PC's runs take about 12 minutes, excluding builds.

  • Where: windows (1-2 reports), linux (1-2 reports).
  • market-wake: from the repository's save kokiri-start (switches HOS_WAKE_LAT=1), then teleport to Market, move the stick, measure market for 60 s (after 0 s warm-up); 1 run on each side.
  • Measured: crashes, the game's log (an expected line that never appears: could not be judged).
  • The PR fails if: it crashes; or forbidden log lines is above 0; or expected log lines missing is above 0.
  • Time: about 12 min of game runs per tester (2 game starts), plus the two builds.
<!-- beanstalk:sticky --> ### Beanstalk test farm · 🔄 testing (0 of 2 reports so far) Commit `4d2ebc2` · approved by futondestroyer (👍 on siantm's request) (reviewed) · [dashboard](https://beanstalk.magicbean.dev/prs/1967) ⚠️ **Note:** Rows are emitted only for threads with more than 100 completed sleeping waits, so no eligible row makes the expected-line check inconclusive. ⚠️ **Note:** The farm cannot verify the five-second cadence or compare the repeat count numerically with the sleeper count; the one-minute measurement is stationary after the movement step. Started at 09:39 UTC. **Estimate:** done in about 40 min, from the queue and the testers online now. | Target | Result | Reports | Frame time p99 (ms), main → PR | VRAM peak (MB) | Crashes | | --- | --- | --- | --- | --- | --- | | `windows` | 🔄 running | 0 of 1 | — | — | — | | `linux` | 🔄 running | 0 of 1 | — | — | — | <details><summary>What was tested</summary> **What will be tested** · AI plan (`gpt-6.1-terra`) On one Windows PC and one Linux PC, the game will run with HOS_WAKE_LAT=1, teleport to Castle Town Market, move, and spend one minute there. The test checks for crashes and an eligible wake log row containing the new numeric count; a missing eligible row is inconclusive. Each PC's runs take about 12 minutes, excluding builds. - **Where:** windows (1-2 reports), linux (1-2 reports). - **market-wake:** from the repository's save `kokiri-start` (switches `HOS_WAKE_LAT=1`), then teleport to Market, move the stick, measure market for 60 s (after 0 s warm-up); 1 run on each side. - **Measured:** crashes, the game's log (an expected line that never appears: could not be judged). - **The PR fails if:** it crashes; or forbidden log lines is above 0; or expected log lines missing is above 0. - **Time:** about 12 min of game runs per tester (2 game starts), plus the two builds. </details>
Author
Contributor

@Beanstalk This replaces my request 63555 on this head (please do not run that one): the same check, with the start and the scene pinned as the reviewer asked. This touches only the HOS_WAKE_LAT diagnostic (off unless set) in the guest event and queue waits (host/nn_os_sync.c): its wake log lines also count the event sleepers that slept more than once. Nothing is meant to get faster. Please start both sides from the kokiri-start save, teleport to Market_Child and check the game arrived there before the one-minute window, then play Castle Town Market for one minute with HOS_WAKE_LAT=1, the PR against main on the same PC, on a Windows PC and on a Linux PC. No crash; on the PR's side, look for a wake row eligible for the new count with its "of them more than once" figure: zero repeats is a valid result, and no eligible row makes it inconclusive.

@Beanstalk This replaces my request 63555 on this head (please do not run that one): the same check, with the start and the scene pinned as the reviewer asked. This touches only the HOS_WAKE_LAT diagnostic (off unless set) in the guest event and queue waits (host/nn_os_sync.c): its wake log lines also count the event sleepers that slept more than once. Nothing is meant to get faster. Please start both sides from the kokiri-start save, teleport to Market_Child and check the game arrived there before the one-minute window, then play Castle Town Market for one minute with HOS_WAKE_LAT=1, the PR against main on the same PC, on a Windows PC and on a Linux PC. No crash; on the PR's side, look for a wake row eligible for the new count with its "of them more than once" figure: zero repeats is a valid result, and no eligible row makes it inconclusive.
Member

@siantm only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@siantm only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
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
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 22s
beanstalk/approval approved by futondestroyer (reviewed)
beanstalk/windows 0/1 pass, 2 running, 0 queued
beanstalk/linux 0/1 pass, 2 running, 0 queued
This pull request is marked as a work in progress.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'feat/wake-lat-resleeps:siantm-feat/wake-lat-resleeps'
git switch 'siantm-feat/wake-lat-resleeps'
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!1967
No description provided.