umem: write the bind log on a writer thread (never block a caller) #134
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/vktory6--VKtory!134
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-134"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@lordra9-svg on GitHub · 2026-12-01 20:08 UTC · original
lordra9-svg:fix/bindlog-async→main· +125 −34 · 1 files · 1 commits · merged 2026-12-01 20:16 UTCWhat it fixes
greenfield/umem/src/bindlog.rswrote the 64 KiB buffer (and theflushedline) to the log file while holding the log mutex, so one slow disk write blocked every thread that logs a bind - the renderer, the descriptor helper and the remapper's bind flush.docs/TASKS.md("The bind log write under its lock stalls every thread for seconds") measured renderer lock waits of 11.3 s and 2.3 s here, with "bind flush: bind log write 2299 ms" and an IO stall. Goal: writing the bind log never blocks a thread that logs a bind; a slow disk costs log lines (dropped and counted), never frames (rule 31).Change
umem-bindlogwriter thread + a bounded queue (4096 lines).line/bind/coalesced/flushedonly formatns <text>andtry_send; they never touch the file.detachreports the count (warn sink).flushedstill reach the file promptly for device-loss decoding.UMEM_BINDLOGunset means no thread and no log, exactly as before. Line format is byte-identical.Tests
umem22 passed, including newoff_spawns_no_thread,full_queue_drops_and_never_blocks(fills the queue, 20k enqueues return well under the test's limit, drop counter exact) andline_format_is_unchanged.VKTORY_BIN=<tmp> tools/build.shexit 0 (built to a separate bin so the running game was untouched).Not measured
I could not reproduce a genuinely slow disk locally, so there is no before/after stall number in this PR; the guarantee is structural (no file IO on any caller) and covered by the full-queue test. Happy to add a disk-stall harness if you want one.
@vktory6 on GitHub · 2026-12-01 20:17 UTC · original
Merged, thanks. That was fast, and it's exactly the shape the task asked for: callers only enqueue, a slow disk costs lines, not frames, and the drop count is reported.
Two notes for next time, no action needed:
VKtory <[email protected]>), probably copied from the repo's history by a tool. Please commit as yourself. The squash merge records you as the author anyway.detach. If it ever matters during a run, putting it in umem's periodic stats line would make it visible live (rule 31's "counted").