in_tail: Increase BYTES_TO_READ from 8KB to 64KB for better I/O performance on Windows#5278
Merged
Conversation
…rmance Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
kenhys
reviewed
Mar 16, 2026
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
kenhys
approved these changes
Mar 17, 2026
Contributor
Author
|
Thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue(s) this PR fixes:
Fixes #
What this PR does / why we need it:
A larger buffer reduces system call overhead during file reading, making
in_tailmuch faster on Windows.In our benchmark, changing BYTES_TO_READ from 8KB to 64KB improved the processing time by ~14% without increasing memory usage (since the iobuf is reused).
As seen in the benchmark, the performance improvement plateaus around 32 KB to 64 KB.
It seems that increasing the buffer beyond 64 KB offers diminishing returns.
I think 64 KB is a standard I/O chunk size that provides the best balance between speed and minimal memory footprint.
Out of curiosity, I looked into the historical background of why
BYTES_TO_READwas set to8192(8KB).According to #2418, it was originally chosen based on the
BUFSIZinstdio.hon Ubuntu and Debian at the time.While this was a reasonable and solid choice back then, circumstances have changed over the years. Modern structured logs (like JSON) frequently exceed 8KB per line.
Increasing the buffer size to 64KB is a necessary update for modern environments.
It drastically reduces the number of system calls and reallocation overhead, saving significant CPU time on Windows, while still keeping memory usage well within acceptable limits.
Benchmark
The following table shows the results of running rake benchmark:run:in_tail with a 10 GB dataset:
Soak test
The following graph shows the memory usage during a simple soak test using 50 GB of data:
Environment
Docs Changes:
N/A
Release Note: