fix(profiling): chain.py loads a HOS_CHAIN recording with an unnamed thread #2352

Merged
HumanBean merged 1 commit from NeoLoger/Longshot:fix/chain-unnamed-thread into main 2026-11-23 16:48:49 +00:00
Contributor

Summary

scripts/perf.py chain could not read a HOS_CHAIN recording from a Steam Deck at all: it stopped with
chain.bin: invalid HOS_CHAIN header. host/hos_chain.c writes one thread <n> <name> line per thread, and a guest
thread the game never named comes out as thread <n> (thread 89 of 96 in that recording). load() in
scripts/profiling/chain.py then indexes a third word that isn't there. Such a thread is now called thread-<n>
and the recording loads.

To see it on main: any recording with an unnamed thread, or the new check in tests/test_chain.py.

Read first: load() in scripts/profiling/chain.py, then check_unnamed_thread() in tests/test_chain.py.

The writer is left as it is, so recordings that already exist load too. Naming such threads in hos_chain.c instead
(like its host-%d) would be a game-side change, and it would not fix old files.

Testing

Tested: Linux (Ubuntu 26.04, Python 3.14.4), inside a no-network bubblewrap sandbox:

  • python -I -B tests/test_chain.py: passes on this branch; with main's chain.py and this test it fails with
    invalid HOS_CHAIN header.
  • The Steam Deck recording that failed (2,097,152 records, 96 threads; recorded on nightly-680 9dd41326, whose
    writer and reader are the same as main's): on main invalid HOS_CHAIN header; here
    96 threads; thread 89 = thread-89; 2097152 records.
  • Not run: the full suite (mise run test).

Still to test:

  • None. The game does not run this script.

Measurements

Nothing to measure: a profiling script and its test.

Risks

None for players: only scripts/perf.py chain reads this. A thread named thread-<n> in its output was unnamed in
the recording. Revert is enough.

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 fix: a game-free test that fails on main and passes here.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
## Summary `scripts/perf.py chain` could not read a HOS_CHAIN recording from a Steam Deck at all: it stopped with `chain.bin: invalid HOS_CHAIN header`. `host/hos_chain.c` writes one `thread <n> <name>` line per thread, and a guest thread the game never named comes out as `thread <n> ` (thread 89 of 96 in that recording). `load()` in `scripts/profiling/chain.py` then indexes a third word that isn't there. Such a thread is now called `thread-<n>` and the recording loads. To see it on main: any recording with an unnamed thread, or the new check in `tests/test_chain.py`. Read first: `load()` in `scripts/profiling/chain.py`, then `check_unnamed_thread()` in `tests/test_chain.py`. The writer is left as it is, so recordings that already exist load too. Naming such threads in `hos_chain.c` instead (like its `host-%d`) would be a game-side change, and it would not fix old files. ## Testing **Tested:** Linux (Ubuntu 26.04, Python 3.14.4), inside a no-network bubblewrap sandbox: - `python -I -B tests/test_chain.py`: passes on this branch; with main's `chain.py` and this test it fails with `invalid HOS_CHAIN header`. - The Steam Deck recording that failed (2,097,152 records, 96 threads; recorded on nightly-680 9dd41326, whose writer and reader are the same as main's): on main `invalid HOS_CHAIN header`; here `96 threads; thread 89 = thread-89; 2097152 records`. - Not run: the full suite (`mise run test`). **Still to test:** - None. The game does not run this script. ## Measurements Nothing to measure: a profiling script and its test. ## Risks None for players: only `scripts/perf.py chain` reads this. A thread named `thread-<n>` in its output was unnamed in the recording. Revert is enough. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [ ] `mise run test` passes (any failure that also fails on `main` is named). - [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 fix: a game-free test that fails on `main` and passes here. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers.
fix(profiling): chain.py loads a HOS_CHAIN recording with an unnamed thread
Some checks failed
PR description / Description follows the template (pull_request_target) Failing after 4s
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
5352dea468
host/hos_chain.c writes `thread <n> <name>` for each thread; a guest thread the game never named comes out as
`thread <n> ` (one word short), and load() then stops with "invalid HOS_CHAIN header", so `scripts/perf.py chain`
cannot read the recording at all. Seen in a Steam Deck recording (thread 89 of 96). The thread is now called
`thread-<n>`. tests/test_chain.py gains a made-up header with an unnamed thread; it fails on main.

Assisted-by: Claude (T.A.L.I. agent)
NeoLoger force-pushed fix/chain-unnamed-thread from 5352dea468
Some checks failed
PR description / Description follows the template (pull_request_target) Failing after 4s
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 ca40376e05
Some checks failed
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
PR description / Description follows the template (pull_request_target) Failing after 4s
2026-11-23 09:10:58 +00:00
Compare
HumanBean deleted branch fix/chain-unnamed-thread 2026-11-23 16:48:50 +00:00
Some checks failed
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
PR description / Description follows the template (pull_request_target) Failing after 4s
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2352
No description provided.