mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 04:49:57 -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:
@@ -23,6 +23,7 @@ void rt_logf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
|
||||
void rt_vlogf(const char *fmt, va_list ap);
|
||||
void rt_log_raw(const char *p, size_t n);
|
||||
const char *rt_log_path(void); // the log file, NULL when this run writes none
|
||||
void rt_log_sync(void); // writes the queued log lines now; later lines are written as they are made
|
||||
enum { RT_TRACE_SVC = 1, RT_TRACE_HOSTCALL = 2, RT_TRACE_IPC = 4, RT_TRACE_FS = 8, RT_TRACE_GFX = 16, RT_TRACE_PERF = 32,
|
||||
RT_TRACE_SCHED = 64, RT_TRACE_AUDIO = 128, RT_TRACE_PRESENT = 256 };
|
||||
extern unsigned rt_trace; // from NX2NAVI_TRACE=svc,host,ipc,fs,gfx,perf,sched,audio,present (or all)
|
||||
|
||||
Reference in New Issue
Block a user