- Author
- Chris Wellons
- Published
- 5 November 2026
- Kind
- Personal blog post, with C code sketches
- Original
- nullprogram.com/blog/2026/11/05/
- Subject
- Systems and hardware
What it is
Chris Wellons writes the nullprogram blog. This post is about output buffering in C programs. It sets out to show that prompt terminal output and fully buffered speed can coexist.
What it says
- The post calls line buffering a common bottleneck. People redirect output to files to avoid it.
- The post shows glibc splitting writes at each newline, even inside one string.
- The post says CPython flushes when its buffer holds a newline. Partial lines may be written.
- The proposed fix borrows Nagle's algorithm: flush the buffer after a short idle time.
- The deadline would be near 100ms, checked between bursts of work with no extra threads.
- In the author's tugz unzip, the file listing looks the same but costs little.
What evidence it gives
The post prints strace-style write traces for glibc and CPython. It gives a small C buffer with a deadline-based flush. It describes the unzip case from the author's own experience. It reports no benchmark numbers.
Interests and limits
The author is describing the author's own tool, tugz. No timings are shown for the speed claim. The code is a sketch, and other platforms and edge cases are not tested. The post is short and makes a narrow case.