It would be good if the terminal types could have built-in buffering, preferably line-buffering. Currently, every write call in a formatter directly causes a syscall, slowing terminal output down. Additionally, there's no need to flush after every color code on ANSI terminals, it would be more efficient to output them together with the actual text.
In https://github.com/slog-rs/slog/issues/125 you can see that it causes a more than 2x speedup to simply put a LineBuffer around the terminal. On Windows, this would also need to include a flush before the terminal properties are changed to output in a different color.
It would be good if the terminal types could have built-in buffering, preferably line-buffering. Currently, every
write
call in a formatter directly causes a syscall, slowing terminal output down. Additionally, there's no need to flush after every color code on ANSI terminals, it would be more efficient to output them together with the actual text.In https://github.com/slog-rs/slog/issues/125 you can see that it causes a more than 2x speedup to simply put a
LineBuffer
around the terminal. On Windows, this would also need to include a flush before the terminal properties are changed to output in a different color.