-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
cat: Improve performance of formatting. #7519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Benchmarking with this change...
So still not as fast as GNU, but a big improvement. I'll try some other things too, but I'd like to get this change mainlined as-is, and anything else I can come up with I'll do in a separate PR. |
src/uu/cat/src/cat.rs
Outdated
@@ -511,7 +511,8 @@ fn write_lines<R: FdReadable>( | |||
) -> CatResult<()> { | |||
let mut in_buf = [0; 1024 * 31]; | |||
let stdout = io::stdout(); | |||
let mut writer = stdout.lock(); | |||
let stdout = stdout.lock(); | |||
let mut writer = BufWriter::with_capacity(1024 * 32, stdout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please document these numbers
kudos :) |
GNU testsuite comparison:
|
GNU testsuite comparison:
|
Hmm - cat-buf test is failing, I'll take a look... |
294fd55
to
3d1fd05
Compare
cat-buf fixed. I had to add some extra buffer-flushing. I re-ran my benchmark after this change and it's still looking good (numbers haven't changes significantly). |
GNU testsuite comparison:
|
@karlmcdowall you closed it, was it on purpose ? :) |
Yeah! I wanted to check something related to the is_interactive flag in the code... I've managed to convince myself there isn't an issue there though, just some other potential optimizations to keep in mind for the future (which I'll write up at some point). |
GNU testsuite comparison:
|
Issue uutils#7518 Add a BufWriter over stdout when cat outputs any kind of formattted data. This improves performance considerably.
GNU testsuite comparison:
|
Issue #7518
Add a BufWriter over stdout when cat outputs any kind of formattted data. This improves performance considerably.