Line buffering is a bottleneck — and we can do better

We can do better than line-buffered output

Line buffering flushes on every newline, which makes programs like unzip crawl when printing many files to a terminal. The author proposes a deadline-based flush: hold output briefly (around 100ms) and send it in batches, poked between short stints of work rather than by a thread. The result looks instant to humans while running at fully buffered speed, as implemented in his tugz unzip.

We can have our cake and eat it, too: promptly delivering lines to a terminal at fully-buffered speeds.

More from this day

2026-11-05