Repository navigation
Conversation
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Escape default to string
escape_default.to_string()str.escape_default().to_string()
d84886a to
b174232
Compare
|
💔 Test for cc7c194 failed: CI. Failed job:
|
This comment has been minimized.
This comment has been minimized.
b174232 to
7607658
Compare
|
@bors try |
This comment has been minimized.
This comment has been minimized.
Optimize `str.escape_default().to_string()`
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (04d7a20): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 4.1%, secondary -1.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.3%, secondary 0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 489.346s -> 491.932s (0.53%) |
|
A perhaps obvious question: would it be worth it to perform to check first whether escape is required, and only then allocate a It's only pertinent, of course, if this function is regularly enough called with symbols which do not require escaping. But the idea of allocating a Implementation-wise, this can still be single-pass:
|
|
Sadly, no, |
I'm confused as to how that relates to escaping I'm not talking about in-place escaping, but avoiding allocating a new string when there's nothing to escape... |
|
Oh, for |
|
I did some benchmarks locally. I took the 30 MiB file from The data below shows instruction counts. In the unlucky (unlikely?) case where the string is long, and escaping must happen from the start, using So I think that we should land the start skipping, and then either continue using manual escaping, or add support for @matthieu-m Since it is essentially your code, do you want to send a PR? :) |
|
@Kobzol I have fairly little time available at the moment, so I'm happy for anyone to pick this up rather than wait on me. (I'm also unsure which approach is best, I feel like @the8472's suggestion of having the standard library returning |
|
Ok, opened #160453. Added you as a co-author of the commit. |
Add fast path to `escape_string_symbol` Discussed in rust-lang#159916. So far used the manual escaping variant. CC @matthieu-m r? the8472
This comment has been minimized.
This comment has been minimized.
Rollup merge of #160453 - Kobzol:include-blob-opt, r=the8472 Add fast path to `escape_string_symbol` Discussed in #159916. So far used the manual escaping variant. CC @matthieu-m r? the8472
Add fast path to `escape_string_symbol` Discussed in rust-lang/rust#159916. So far used the manual escaping variant. CC @matthieu-m r? the8472
7607658 to
889d55c
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
889d55c to
7d56173
Compare
This comment has been minimized.
This comment has been minimized.
7d56173 to
5274070
Compare
This comment has been minimized.
This comment has been minimized.
and Extend for String too
This reverts commit bfe8ccb.
5274070 to
01202dd
Compare
|
@bors try |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Optimize `str.escape_default().to_string()`
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (467e496): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=iffy rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 2.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -1.3%, secondary -4.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 1.6%, secondary 0.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 489.893s -> 489.319s (-0.12%) |
|
After #160453 perf now looks like noise, but this PR uplifts part of the optimization from a compiler-internal use to all users of std. I also looked into specializing @rustbot ready |
View all comments
reverts #159609 and implements the optimization in std instead.
bench results in my machine: