fd/src
Tavian Barnes 16c2d1e1d0 walk: Flush stdout in batches
The previous behaviour was designed to mimic the output buffering of
typical UNIX tools: line-buffered if stdout is a TTY, and fully-buffered
otherwise.  More precicely, when printing to a terminal, fd would flush
explicitly after printing any buffered results, then flush after every
single result once streaming mode started.  When not printing to a
terminal, fd never explicitly flushed, so writes would only happen as
the BufWriter filled up.

The new behaviour actually unifies the TTY and non-TTY cases: we flush
after printing the buffered results, then once we start streaming, we
flush after each batch, but *only when the channel is empty*.  This
provides a good balance: if the channel is empty, the receiver thread
might as well flush before it goes to sleep waiting for more results.
If the channel is non-empty, we might as well process those results
before deciding to flush.

For TTYs, this should improve performance by consolidating write() calls
without sacrificing interactivity.  For non-TTYs, we'll be flushing more
often, but only when the receiver would otherwise have nothing to do,
thus improving interactivity without sacrificing performance.  This is
particularly handy when fd is piped into another command (such as head
or grep): with the old behaviour, fd could wait for the whole traversal
to finish before printing anything.  With the new behaviour, fd will
print those results soon after they are received.

Fixes #1313.
2023-12-18 22:01:11 +01:00
..
exec walk: Send WorkerResults in batches 2023-11-28 15:51:33 -05:00
filter maint: Remove use of unmaintained users crate 2023-10-21 23:37:32 -06:00
cli.rs cli: Tweak default thread count logic 2023-12-18 21:55:18 +01:00
config.rs Add flag --no-require-git to always respect gitignore files 2023-01-13 13:52:34 -08:00
dir_entry.rs walk: Send WorkerResults in batches 2023-11-28 15:51:33 -05:00
error.rs Proper error handling within walk.rs 2020-04-03 22:36:32 +02:00
exit_codes.rs Fix clippy suggestions 2022-09-11 21:29:43 +02:00
filesystem.rs Support character and block device file types 2023-10-21 13:56:33 +02:00
filetypes.rs Support character and block device file types 2023-10-21 13:56:33 +02:00
main.rs fix: display color when NO_COLOR is an empty string 2023-11-04 15:07:10 +01:00
output.rs Use nu-ansi-term instead of ansi-term 2022-12-01 00:07:30 -07:00
regex_helper.rs Upgrade regex and regex-syntax 2023-08-09 01:02:55 -06:00
walk.rs walk: Flush stdout in batches 2023-12-18 22:01:11 +01:00