mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-16 07:31:06 -04:00
Keep a thread's log lines in order when the log queue's lock is taken.
A thread that found the queue's lock taken for 4,000 spins wrote its line itself, ahead of the lines it had queued earlier. On a busy machine the lock's holder loses the processor inside the copy and the lock stays taken for a time slice, so one thread's lines reached the log out of order. A line now waits for the lock, and a line that finds no room, or is larger than the queue, is written after everything queued before it. tests/logq_check.py failed on this in 8 of 30 runs beside four busy processes and passes 100 of 100 now. It gained a check that holds the queue's locks itself and fails on the old code every time, and it no longer depends on time: it waits for the queue to empty, keeps the line about slow writes back except in the step that checks it, and counts the lines that waited instead of timing the slowest. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -41,9 +41,10 @@ from other projects, with its license, is listed in [THIRD_PARTY_NOTICES.md](../
|
||||
variables and written back when the in-game menu changes it. The menu and the performance overlay are Dear ImGui,
|
||||
drawn into the swapchain image (`runtime/ui/`); their text is in `ui_text.c`.
|
||||
- Log: in a game run the lines go through a queue to a thread that writes them (`runtime/logq.c`), so a stalled
|
||||
write to the log file or the console does not hold the thread that logged; a fatal error, the crash report and the
|
||||
end of the process write the queue out first (`rt_log_sync`). `NX2NAVI_LOG_ASYNC=0` writes each line where it is
|
||||
logged.
|
||||
write to the log file or the console does not hold the thread that logged. A thread's lines reach the log in the
|
||||
order it logged them: a line waits for the queue's lock, and one that finds the queue full is written after
|
||||
everything queued before it. A fatal error, the crash report and the end of the process write the queue out first
|
||||
(`rt_log_sync`). `NX2NAVI_LOG_ASYNC=0` writes each line where it is logged.
|
||||
- OS calls the host makes go through `runtime/platform/` (`platform.h`, `win32.c`).
|
||||
|
||||
#### Threads and cores
|
||||
|
||||
@@ -307,9 +307,12 @@ the wait on it, timed waits keep their time, a cancel ends any wait, and 4,000 s
|
||||
each seen. It runs a second time with `NX2NAVI_SYNC_WAKE_ALL=1`. No game files.
|
||||
|
||||
A change to the log queue (`runtime/logq.c`) passes `python tests\logq_check.py`, which builds it with the platform
|
||||
layer and a destination of its own: 160,000 lines from eight threads arrive whole and in each thread's order, a
|
||||
destination that takes 30 ms a write does not hold the threads that log, one that stops while four times the queue's
|
||||
size is logged loses nothing, and `logq_sync` returns with everything written. No game files.
|
||||
layer and a destination of its own: 160,000 lines from eight threads arrive whole and in each thread's order, a line
|
||||
logged while the queue's lock is taken waits and does not pass the lines queued before it, a destination that takes
|
||||
30 ms a write does not hold the threads that log, the line about slow writes comes once in ten seconds, a destination
|
||||
that stops while four times the queue's size is logged loses nothing, and `logq_sync` returns with everything written.
|
||||
The test passes on a busy machine too: it waits for the queue to empty instead of for a time, and counts slow lines
|
||||
instead of timing one. No game files.
|
||||
|
||||
A change to the button prompts (`tools/make_romfs_patches.py --prompts`, `tools/button_icons.py`) passes
|
||||
`.venv-py314\Scripts\python tests\romfs_prompts_test.py`, which runs the tool on a RomFS it makes itself (no game
|
||||
|
||||
Reference in New Issue
Block a user