Alloc String::retain optimization - #150067
Conversation
|
rustbot has assigned @Mark-Simulacrum. Use |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Alloc `String::retain` optimization
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (2621d01): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible 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 -2.1%, secondary 0.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 68.5%, secondary -2.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 479.038s -> 478.434s (-0.13%) |
|
r? joboet Probably makes sense to have the same reviewer for both. |
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bc23951 to
875c63d
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. |
66f0f66 to
2af59e0
Compare
|
@fereidani Hi, ping from triage team. This PR has been inactive for a while. There are still some review comments that need to be addressed. Would you like to proceed with this PR? Thanks. |
|
@SpriteOvO @joboet Please excuse the delay. My country is currently at war, and our government has cut off internet access for our people for over two months now. Now that I have a somewhat workable connection, I’ll try to complete the PR within the next few days. Thank you for your understanding. |
|
@fereidani Oh, so sorry to hear that. No need to hurry at all here. Feel free to come back to this when you have time, staying safe first. |
|
|
Please excuse my delay. Let me know when to clean up the tree and make it a single commit. |
This comment has been minimized.
This comment has been minimized.
|
Thank you my friend, I'm happy to be back, It's a privilege for me to have you as my reviewer. // SAFETY: `read..read + ch_len` is in bounds and `g.write < read`.
//
// The match makes every copy length constant so LLVM expands
// it inline; a dynamic-length `ptr::copy` lowers to a
// `memmove` call per retained character.
unsafe {
let src = ptr.add(read);
let dst = ptr.add(g.write);
match ch_len {
1 => ptr::copy(src, dst, 1),
2 => ptr::copy(src, dst, 2),
3 => ptr::copy(src, dst, 3),
_ => ptr::copy(src, dst, 4),
}
}It optimizes better and it is about 3.5x faster when match is optimizable. |
7373b61 to
6a24a6e
Compare
|
Thanks! I fixed the problems and squashed the commits into one commit. |
|
Thank you, looks great! |
…uwer Rollup of 4 pull requests Successful merges: - rust-lang/rust#150067 (Alloc `String::retain` optimization) - rust-lang/rust#153973 (std::process: fix UEFI ExitStatus::code() silent truncation of error …) - rust-lang/rust#161690 (Deny #[inline] on EII declarations) - rust-lang/rust#161701 (Rename dlltool helper function)
View all comments
Hi again!
This uses the exact same algorithm as my other PR: #149784
Technically it should improve performance for
String::retaintoo, But let's see what bors thinks.