Commit Graph
22 Commits
Author SHA1 Message Date
Valiantsin DzerakhandClaude Opus 5.5 ce150130df Make code comments say what they mean instead of pointing at things a reader cannot follow
Comments cited codes from local notes (port-lessons P1, backlog), task labels (T6c1-T6c3, M4), bare upstream commit
hashes and issue numbers, a file that no longer exists (nvn_api.c, now nvn_api_*.c), a generated file (main_0103.c)
and line numbers into upstream files that refs/ has moved past, so they pointed at unrelated code. Those now name the
file, function or project and say what the cited code does. Attribution of copied code keeps its pinned commits.

Corrected facts: TOTK_REPLAY_ASYNC defaults to 0, and the shader cache, pipeline cache and pipeline keys live next to
totk.exe, not in build/v121.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 12:58:01 +03:00
Valiantsin DzerakhandClaude Opus 5.5 4e764cd39a Take world-clock windows in TOTK_PROFILE_FRAMES and TOTK_CRIT: w<lo>-<hi> is seconds of game time since the save loaded, so a profile or critical-path session covers the same play at any frame rate instead of a present range that lands elsewhere on a slow machine
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 08:56:50 +03:00
Valiantsin DzerakhandClaude Opus 5.5 c2943970cc Merge the spin wait gates: they also end the fight hangs
The generator emits a guest poll such as `ldr w9, [x19]; cmp w9, #1; b.eq` as a plain C load, and clang hoists it out
of the loop: the lock wait in f_7001fa0e2c compiled to `cmp; jne; jmp .`, so a thread that found the lock held spun
forever after its holder released it. A fight run hung this way in 3 of 13 launches on an RX 9070, with the UBO
snapshot on and off; gdb showed the thread on that `jmp` in every sample. The gate is an opaque call on every
back-edge of the 868 loops tools/spin_waits.py lists, so each pass reloads memory: the exe goes from 182 self-jumps to
148, and 144 of those are the game's own `b .` instructions. 8 of 8 fight runs then passed; tests/diff/func.py with
--patches passed 5470 cases on 878 functions, and the four probes passed on 1.4.3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 20:05:44 +03:00
Valiantsin DzerakhandClaude Opus 5.5 5da6c5bb89 Merge the frame critical path recorder: TOTK_CRIT=<first>-<last frame> with TOTK_TRACE=sched writes the guest threads' state changes and wakes, read by tools/crit_path.py
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 14:13:40 +03:00
Valiantsin DzerakhandClaude Opus 5.5 2fe6a6d4c1 Keep MXCSR in line with FPCR where FPCR changes instead of checking it in every FP op
The FP helpers compared c->fpcr with a cached copy before every operation to resync MXCSR lazily. MXCSR now
follows FPCR.FZ at once: MSR FPCR calls rt_fpcr_sync, and so do rt_call (thread, fiber and host entry into guest
code), fiber resume (FIBER_FLAG_FLOAT_SWITCH fibers keep their own MXCSR) and the differential test harness per
case. op and vop only test FPCR.RMode for the slow path, and their redo check is one ordered-not-equal compare of
|r| with the smallest normal, the same NaN-or-smallest-normal set as before.

Hot guest code shrinks by about a quarter (132 functions holding half the guest cycles, 1.4.3); fight frame time
moves 1-3%, inside the run-to-run spread. lift, simd, func, atomic and flags_check pass on 1.4.3; simd.py fails
without the harness sync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 12:25:25 +03:00
Valiantsin DzerakhandClaude Opus 5.5 ba52fe6e89 Record the critical path of the frame with TOTK_CRIT
With TOTK_TRACE=sched, TOTK_CRIT=<lo>-<hi> records every state change and wake of the guest threads and every
present over those frames (runtime/kernel.c crit_add from acct() and wake(), crit_frame at the present) and writes
them to TOTK_CRIT_OUT at the last frame. tools/crit_path.py walks back from each present through the waits to the
thread whose signal ended them and splits the frame interval by thread and state; the sums equal the interval.

A 1.4.3 fight: with the replay on the submitting thread the path is 7.3 ms of replay on the render thread and 4.3 ms
of guest code; with TOTK_REPLAY_ASYNC=1 it is 10.1 ms of guest code through the fork-join of the main thread and five
workers, at the same frame interval.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 09:26:07 +03:00
Valiantsin DzerakhandClaude Opus 5.5 101f2c8b5e Give the virtual core up in nn::fs host functions and in NVN memory pool setup, as the Switch blocks those threads in IPC: the game's loader threads held a core through CloseFile, CreateCacheStorage and nvnMemoryPoolInitialize (up to 20 ms) while job workers waited. Core diagnostics now also report waits on an owner in a host call, with its module, offset, latest SVC and guest lr, and the AllocateMemoryPages and AllocateAddressRegion lines need TOTK_TRACE=host
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 16:42:14 +03:00
Valiantsin DzerakhandClaude Opus 5.5 3984344635 Spin wait gates: tools/spin_waits.py (the nxnative search) lists the loops that only another thread can end, the patch tables carry them as spin lines (857 in 1.4.3, 864 in 1.2.1), the generator sends their back-edges through rt_spin_gate, and the gate pauses the core once per pass and hands the virtual core to a waiter after 50 us of polling (TOTK_SPIN, TOTK_SPIN_HANDOFF_US)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 15:51:47 +03:00
Valiantsin DzerakhandClaude Opus 5.5 97d3762ba1 Strip milestone and task labels from code comments and drop the dead gfx_stubs.c
Comments named the agent task (T1-T7, M2-M5, Task 2.x) that once owned each file or block, and pointed at local
notes the repository does not carry (backlog items, milestone plans, research notes). They now say what the code
does. gfx_stubs.c held weak stand-ins for functions that every build has defined for a long time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:12:50 +03:00
Valiantsin DzerakhandClaude Opus 5.5 42b73c4098 Note what each 2026-10 frame time fix needs on a Linux host: the SleepThread spin is for the Windows timer only, the file I/O moved off the game and render threads is portable with fsync in place of FlushFileBuffers, the slow-present profiler is Windows-only
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 13:01:22 +03:00
Valiantsin DzerakhandClaude Opus 5.5 95ae91687c Spin short SleepThread calls on the performance counter: the high-resolution waitable timer ended the SDK's 20 us polling sleeps after 460-515 us on the main thread and the job workers; the sched trace now reports wake-to-run and core-grant-to-run latency and asked versus taken sleep time per thread
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 10:17:13 +03:00
Valiantsin DzerakhandClaude Opus 5.5 bd9851f4f2 Trace the guest main thread's waits by object and by the thread whose signal ended them (TOTK_TRACE=sched), and sample the main thread alone with call chains (TOTK_PROFILE_MAIN=1)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 09:23:35 +03:00
Valiantsin DzerakhandClaude Opus 5.5 b0805112ed Merge main into task/menu: the docs and comment cleanup, with the Dear ImGui set-up of menu.cpp kept in the LAS Recomp notices row
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 10:16:23 +03:00
Valiantsin DzerakhandClaude Opus 5.5 8b514f6ead Keep every default in the settings table: cfg_value, cfg_int, cfg_double and cfg_bool read it, and the consumers of table keys drop their own defaults
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 09:32:30 +03:00
Valiantsin DzerakhandClaude Opus 5.5 7b85a2681a Keep free_cores=0 as gate on, refuse to rewrite totk.ini after a failed read, drop empty-valued lines on Reset, and add plat_file_set_readonly and plat_file_size
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 09:23:55 +03:00
Valiantsin DzerakhandClaude Opus 5.5 111f748c51 Remove citations of local build/ notes from code comments and correct the TOTK_REPLAY_ASYNC default in vk_backend.c
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 09:23:21 +03:00
Valiantsin DzerakhandClaude Opus 5.5 8553b00c9b Drop the bisect modes 3 to 5 of TOTK_ASYNC_PREEMPT and log interrupts after the owner is resumed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 07:44:47 +03:00
Valiantsin DzerakhandClaude Opus 5.5 8f9716527a Keep the interrupted code's flags in kern_ap_stub, take the whole integer context, log the first interrupts and add test modes 2 to 5 of TOTK_ASYNC_PREEMPT
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 00:03:10 +03:00
Valiantsin DzerakhandClaude Opus 5.5 9fea5cc37b Credit MacNativeGames for the virtual-core preemption in THIRD_PARTY_NOTICES.md and the kernel.c header
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 23:49:11 +03:00
Valiantsin DzerakhandClaude Opus 5.5 c66ac84925 Preempt a virtual core owner in top-level game code from the waiting thread, with priority inheritance and the SDK's preemption disable, behind TOTK_ASYNC_PREEMPT
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 23:37:11 +03:00
Valiantsin DzerakhandClaude Opus 5.5 d52cdfc6ee Add TOTK_CORE_DIAG: classify every virtual core wait by what the owner was doing, and answer SVC 0x36
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 23:23:48 +03:00
Valiantsin DzerakhandClaude Opus 5.5 19c9b648d1 Add the recompiler, Windows runtime, tools and docs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 22:27:54 +03:00