-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Reserve before write_fmt
for owned buffers
#137762
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
base: master
Are you sure you want to change the base?
Reserve before write_fmt
for owned buffers
#137762
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
…e-fmt, r=<try> Reserve before `write_fmt` `fmt::Arguments::estimated_capacity()` is currently only used for `fmt::format()` to reserve the initial string capacity. Also use it for `impl Write` for `Vec<u8>`, `VecDeque<u8>`, `Cursor<&mut Vec<u8>>`, and `Cursor<Vec<u8>>`. This may be worth checking perf.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (9cdfd5d): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary 10.1%)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.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResults (primary 0.0%, secondary 0.1%)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.
Bootstrap: 770.19s -> 771.304s (0.14%) |
No regressions, so are we good? Also, it probably shouldn't be rollup=never. |
0e82180
to
d8b6fe8
Compare
I had only considered the |
I think the @bors try @rust-timer queue |
@thaliaarchi: 🔑 Insufficient privileges: not in try users |
This comment has been minimized.
This comment has been minimized.
rustdoc uses a lot of formatting, so this might have a positive impact there |
This comment has been minimized.
This comment has been minimized.
…e-fmt, r=<try> Reserve before `write_fmt` `fmt::Arguments::estimated_capacity()` is currently only used by `fmt::format()` to reserve the initial string capacity. Also use it for `impl Write` for `Vec<u8>`, `VecDeque<u8>`, `Cursor<&mut Vec<u8>>`, and `Cursor<Vec<u8>>`. This may be worth checking perf.
☀️ Try build successful - checks-actions |
Reserve before formatting with `fmt::Arguments::estimated_capacity()` in `fmt::Write::write_fmt` and `io::Write::write_fmt` implementations for owned buffer types. Adding `#[inline]` to `write_fmt` shows minor perf regressions, so leave it off like the default impl.
295e573
to
b0a8187
Compare
@workingjubilee you should probably just approve this one yeah? thanks. |
yes I agree @workingjubilee, we should get this show on the road. @bors r+ rollup |
hmm well @bors rollup=maybe |
@bors rollup=never There that's what I wanted to put back. |
Huh. I never actually finished investigating whether the Sorry, I was thinking of this as waiting-on-author or draft, but hadn't marked it as such. |
…e-fmt, r=workingjubilee Reserve before `write_fmt` for owned buffers `fmt::Arguments::estimated_capacity()` is currently only used by `fmt::format()` to reserve the initial string capacity. Also use it in `fmt::Write::write_fmt` for `String` and `OsString`; and `io::Write::write_fmt` for `Vec<u8>`, `VecDeque<u8>`, `Cursor<&mut Vec<u8>>`, and `Cursor<Vec<u8>>`. This may be worth checking perf.
I checked cachegrind on the biggest doc regression of the perf run and found this:
as usual inlining noise makes it harder to understand, but it does look like it's spending more instructions (which of course don't necessarily have to mean that it's actually slower, but it's a sign) around the code you changed, generally (formatting and appending things to vecs). rustdoc uses a lot of formatting into strings |
Since this could have a lot of fallout if it's not right, we should pop it from the queue and I should write proper benchmarks, instead of leaning on compile benchmarks. The positive deltas in the Cachegrind results are more than the negative and it seems like it moved where the impact of the reserve happens (hence the different inlining?). |
I'm going to close it and reopen to cancel the merge. |
@bors r- |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
It seemed Okay. If there was something I missed in my decision-making, it was probably because of the loss in context over time. I definitely don't want to ship something that you aren't happy with yet, obviously. |
This code is fine, yeah; the possible problem is in code it uses, |
fmt::Arguments::estimated_capacity()
is currently only used byfmt::format()
to reserve the initial string capacity. Also use it infmt::Write::write_fmt
forString
andOsString
; andio::Write::write_fmt
forVec<u8>
,VecDeque<u8>
,Cursor<&mut Vec<u8>>
, andCursor<Vec<u8>>
.This may be worth checking perf.