mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 11:29:58 -04:00
Write the log from a thread of its own, so a stalled write no longer holds the thread that logged.
Every log line was two writes on the thread that logged it, to stderr and to the log file. Such a write can stall for tens or hundreds of milliseconds (a busy disk, a virus scanner, a console or a pipe that is slow to take it), and the render thread logs too: a frame it spent in a write was a hitch with nothing else to show for it. In a game run the lines now go into a queue that a log thread writes out in order (runtime/logq.c). A fatal error, the crash report and the end of the process write the queue out on their own thread first and write their own lines directly, so nothing is lost to an exit. A thread that finds the queue's lock held for long, or the queue full, writes its line itself. NX2NAVI_LOG_ASYNC=0 writes every line where it is logged, as before. Every write is timed in both modes: a "log: ... writes of the log took over 2 ms" line counts the slow ones, gives the longest and says whose time they took. tests/logq_check.py checks order and completeness with eight threads, a slow destination, a stopped destination with the queue full, and the synchronous flush. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -40,6 +40,10 @@ from other projects, with its license, is listed in [THIRD_PARTY_NOTICES.md](../
|
||||
- Settings and menu: every key with its default is in one table (`cfg.c`), read from `nx2navi.ini` and `NX2NAVI_*`
|
||||
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.
|
||||
- OS calls the host makes go through `runtime/platform/` (`platform.h`, `win32.c`).
|
||||
|
||||
#### Threads and cores
|
||||
|
||||
@@ -285,6 +285,11 @@ waits on its event and leaves the others asleep, a wait on several handles repor
|
||||
the wait on it, timed waits keep their time, a cancel ends any wait, and 4,000 signals to eight looping waiters are
|
||||
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.
|
||||
|
||||
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
|
||||
files); a change to the settings passes `nx2navi.exe --probe-cfg`.
|
||||
|
||||
Reference in New Issue
Block a user