mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 04:59:57 -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
|
||||
|
||||
Reference in New Issue
Block a user