-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Avoid short writes in LineWriter #134620
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
Avoid short writes in LineWriter #134620
Conversation
Also update the tests to avoid testing implementation details.
|
Sorry this took so long but looks reasonable! @bors r+ |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
💔 Test failed - checks-actions |
|
@bors retry spurious i686-msvc |
|
(Actually this one is i686-msvc) |
|
Edited for future reference. Too many platforms. |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (7a0cde9): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary -0.2%, secondary 3.5%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (secondary 4.8%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 760.593s -> 759.631s (-0.13%) |
If the bytes written to
LineWritercontains at least one new line but doesn't end in a new line (e.g."abc\ndef") then we:Writer.That last step is inefficient if the remaining bytes are larger than our buffer. It will needlessly split the bytes in two, requiring at least two writes to the underlying
Writer(one to flush the buffer, one more to write the rest). This PR skips the extra buffering if the remaining bytes are larger than the buffer.