Skip to content

Reduce client log buffer from 4096 -> 0 - #302

Open
JiyuSoftware wants to merge 1 commit into
space-wizards:masterfrom
JiyuSoftware:4kb-log-buffer-fix
Open

JiyuSoftware wants to merge 1 commit into
space-wizards:masterfrom
JiyuSoftware:4kb-log-buffer-fix

Conversation

@JiyuSoftware

@JiyuSoftware JiyuSoftware commented Aug 23, 2026

Copy link
Copy Markdown

The stdout and stderr log are currently missing output at the end of every session because the FileStreams are created with a 4KB buffer. So everything that happens in the last 4KB of the log is always discarded and never written to the files.

A little background on how I found this bug:
I am writing a OBS stream overlay that should automatically switch scenes between lobby and gameplay. I tried to make my stream overlay work by parsing the log but it didn't work because the logs are currently not realtime, but in 4KB chunks. So it could take up to 2-4 minutes for the stream overlay to actually update based on the new 4KB chunk to be written to the log.

This rabbit hole goes deeper as well, because while working on this I also found that PipeOutput never properly closes the streams, which can cause other issues (separate PR here: #303)

@Visne

Visne commented Aug 29, 2026

Copy link
Copy Markdown
Member

Not sure if this might cause performance issues if something is spamming the logs, but having accurate log files in case of a crash is definitely important

@JiyuSoftware

Copy link
Copy Markdown
Author

I'm fairly certain that this does not performance issues at all.

With a 4096 buffer you need to read every loop, which is only written once.
A 0 buffer does the opposite, requires no reads but does more writes.

This should make about performance equal in both scenarios.

And besides that we're talking about the performance of a log writer. This code could probably output millions of lines of text per second while your CPU doesn't even break a sweat, far beyond the output of anything the game would ever output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants