Gather the log lines of a quarter of a second and write them at once.

The log thread wrote as soon as it woke, which outside a burst is once for every line: each line woke it and was a write of its own to the log file and the console. It now waits a quarter of a second from the first line it finds, or until the queue is half full, and writes what was queued by then at once, so the log is up to that much behind the game. What is being gathered stays in the queue, so a fatal error, a crash report and an exit write it out before their own lines as before; a game ended from outside loses those last lines. The queue's test checks the gathering, the half-full write and that a process which ends at once, by an exit or as a fatal error does, leaves every line in its file.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-12 15:11:59 -05:00
parent 1c975316a3
commit cc0b467a2c
6 changed files with 143 additions and 16 deletions

View File

@@ -874,9 +874,11 @@
# sync_wake_all = 0
# 1 (default): a thread of its own writes the log lines, to the log file and the console, so a write that stalls (a
# busy disk, a virus scanner, a console that scrolls) no longer holds the thread that logged, which is often the one
# that draws the frame. A crash, a fatal error and the end of the game write out what is still queued first. 0: each
# line is written by the thread that logs it, as before. Either way a "log: ... writes of the log took over 2 ms" line
# counts the slow writes and says whose time they took.
# that draws the frame. It writes the lines of a quarter of a second together, sooner when many are waiting, so the
# log file and the console are up to that much behind the game. A crash, a fatal error and the end of the game write
# out what is still queued first; a game that is ended from outside (Task Manager) loses those last lines. 0: each
# line is written at once by the thread that logs it, as before. Either way a "log: ... writes of the log took over
# 2 ms" line counts the slow writes and says whose time they took.
# log_async = 1
# 1: the frame-time summary also splits the replay by op kind (draw, bind, transfer), which says where a stalled frame
# went. The clock reads cost a fraction of a millisecond a frame, so it is off by default.