Skip to content

perf(date): wrap stdout in BufWriter to improve batch processing - #9994

Merged
sylvestre merged 1 commit into
uutils:mainfrom
CrazyRoka:date-optimize-println
Jan 3, 2026
Merged

perf(date): wrap stdout in BufWriter to improve batch processing#9994
sylvestre merged 1 commit into
uutils:mainfrom
CrazyRoka:date-optimize-println

Conversation

@CrazyRoka

Copy link
Copy Markdown
Contributor

This PR addresses a performance bottleneck when processing large numbers of dates (e.g., using date -f large_file.txt).

Previously, the main loop used println!, which locks and flushes stdout on every iteration. This change wraps stdout in a BufWriter and uses writeln!, significantly improving throughput for batch operations.

@CrazyRoka
CrazyRoka force-pushed the date-optimize-println branch from d6708e5 to b0afcf4 Compare January 2, 2026 21:10
@CrazyRoka
CrazyRoka force-pushed the date-optimize-println branch from b0afcf4 to f0238dc Compare January 2, 2026 21:13
@CrazyRoka

Copy link
Copy Markdown
Contributor Author

Some CodSpeed benchmarks are showing ~30% performance improvement when system calls are included in the measurement (link):

image

@CrazyRoka
CrazyRoka marked this pull request as ready for review January 2, 2026 21:59
@sylvestre
sylvestre merged commit 3df9444 into uutils:main Jan 3, 2026
129 of 130 checks passed
@CrazyRoka
CrazyRoka deleted the date-optimize-println branch January 3, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants