Re: git: ffe47c424e0a - main - grep: periodic timer-based fflush instead of unconditional per-line flush
Date: Sun, 14 Jun 2026 14:49:43 UTC
On Sun 14 Jun 14:27, Baptiste Daroussin wrote: > The branch main has been updated by bapt: > > URL: https://cgit.FreeBSD.org/src/commit/?id=ffe47c424e0a45f5d8d20a5944477821bd946eef > > commit ffe47c424e0a45f5d8d20a5944477821bd946eef > Author: Baptiste Daroussin <bapt@FreeBSD.org> > AuthorDate: 2026-06-12 12:13:35 +0000 > Commit: Baptiste Daroussin <bapt@FreeBSD.org> > CommitDate: 2026-06-14 14:26:30 +0000 > > grep: periodic timer-based fflush instead of unconditional per-line flush > > Replace the unconditional fflush(stdout) in grep_printline and > procmatches with a periodic timer that flushes at most once every > 100ms. This preserves interactive responsiveness (grep | tee, > grep | tail -f) while avoiding 1M+ write(2) syscalls when > processing large inputs. > > The flush interval is tracked via clock_gettime(CLOCK_MONOTONIC) > and a static timespec. --line-buffered continues to flush > immediately via setlinebuf(3), as before. > > Benchmark on 1M lines (37MB output to file): > unconditional fflush: 1.90s (sys 1.22s) > periodic 100ms timer: 0.49s (sys 0.007s) > > Reviewed by: kevans > Differential Revision: https://reviews.freebsd.org/D57528 The actuall review is: https://reviews.freebsd.org/D57563 Best regards Bapt