Optimize `Extend for String`
Implements the idea in https://github.com/rust-lang/rust/pull/148604#issuecomment-3616433682. Enhancement to rust-lang/rust#149694.
Could we get a perf run?
r? @joboet
rustbot has assigned @joboet. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.
Use r? to explicitly pick a reviewer
The job aarch64-gnu-llvm-20-2 failed! Check out the build log: (web) (plain enhanced) (plain)
Click to see the possible cause of the failure (guessed by this bot)
fmt: checked 6590 files
tidy check
tidy [rustdoc_json (src)]: `rustdoc-json-types` modified, checking format version
tidy: Skipping binary file check, read-only filesystem
tidy [style (library)]: /checkout/library/alloc/src/string.rs:2236: TODO is used for tasks that should be done before merging a PR; If you want to leave a message in the codebase use FIXME
tidy [style (library)]: /checkout/library/alloc/src/string.rs:2238: TODO is used for tasks that should be done before merging a PR; If you want to leave a message in the codebase use FIXME
tidy [style (library)]: FAIL
tidy: The following check failed: style (library)
Command `/checkout/obj/build/aarch64-unknown-linux-gnu/stage1-tools-bin/rust-tidy /checkout /checkout/obj/build/aarch64-unknown-linux-gnu/stage0/bin/cargo /checkout/obj/build 4 yarn` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1612:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1314:29
Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `--stage 2 test --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Build completed unsuccessfully in 0:00:50
local time: Sat Dec 6 09:12:47 UTC 2025
network time: Sat, 06 Dec 2025 09:12:47 GMT
##[error]Process completed with exit code 1.
@bors try @rust-timer queue
Awaiting bors try build completion.
@rustbot label: +S-waiting-on-perf
:hourglass: Trying commit 207e484ecbfe2c33b42d7d6a4340735f09e2a2f7 with merge 3f3acdfbe44242af2a9a5419227d7c20c118425e…
To cancel the try build, run the command @bors try cancel.
Workflow: https://github.com/rust-lang/rust/actions/runs/19987302088
:sunny: Try build successful (CI)
Build commit: 3f3acdfbe44242af2a9a5419227d7c20c118425e (3f3acdfbe44242af2a9a5419227d7c20c118425e, parent: fbab541a7ad1c22fc51783d03c7d75fa577f5633)
Queued 3f3acdfbe44242af2a9a5419227d7c20c118425e with parent fbab541a7ad1c22fc51783d03c7d75fa577f5633, future comparison URL. There is currently 1 preceding artifact in the queue. It will probably take at least ~2.3 hours until the benchmark run finishes.
Finished benchmarking commit (3f3acdfbe44242af2a9a5419227d7c20c118425e): comparison URL.
Overall result: ❌✅ regressions and improvements - please read the text below
Benchmarking 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.
Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.
@bors rollup=never @rustbot label: -S-waiting-on-perf +perf-regression
Instruction count
Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
- | - | 0 |
| Regressions ❌ (secondary) |
0.1% | [0.1%, 0.2%] | 3 |
| Improvements ✅ (primary) |
-1.1% | [-1.1%, -1.1%] | 1 |
| Improvements ✅ (secondary) |
-0.4% | [-1.3%, -0.1%] | 4 |
| All ❌✅ (primary) | -1.1% | [-1.1%, -1.1%] | 1 |
Max RSS (memory usage)
Results (secondary -2.4%)
A less reliable metric. May be of interest, but not used to determine the overall result above.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
- | - | 0 |
| Regressions ❌ (secondary) |
1.1% | [0.8%, 1.7%] | 4 |
| Improvements ✅ (primary) |
- | - | 0 |
| Improvements ✅ (secondary) |
-3.7% | [-6.4%, -0.9%] | 11 |
| All ❌✅ (primary) | - | - | 0 |
Cycles
Results (primary -3.2%, secondary 1.4%)
A less reliable metric. May be of interest, but not used to determine the overall result above.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
- | - | 0 |
| Regressions ❌ (secondary) |
3.7% | [2.1%, 6.6%] | 7 |
| Improvements ✅ (primary) |
-3.2% | [-3.2%, -3.2%] | 1 |
| Improvements ✅ (secondary) |
-6.5% | [-6.8%, -6.2%] | 2 |
| All ❌✅ (primary) | -3.2% | [-3.2%, -3.2%] | 1 |
Binary size
Results (primary -0.1%, secondary -0.1%)
A less reliable metric. May be of interest, but not used to determine the overall result above.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
- | - | 0 |
| Regressions ❌ (secondary) |
- | - | 0 |
| Improvements ✅ (primary) |
-0.1% | [-1.1%, -0.0%] | 30 |
| Improvements ✅ (secondary) |
-0.1% | [-0.1%, -0.0%] | 23 |
| All ❌✅ (primary) | -0.1% | [-1.1%, -0.0%] | 30 |
Bootstrap: 471.701s -> 471.964s (0.06%) Artifact size: 388.90 MiB -> 388.53 MiB (-0.09%)
The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)
Click to see the possible cause of the failure (guessed by this bot)
fmt: checked 6594 files
tidy check
tidy [rustdoc_json (src)]: `rustdoc-json-types` modified, checking format version
tidy: Skipping binary file check, read-only filesystem
tidy [style (library)]: /checkout/library/alloc/src/string.rs:2638: TODO is used for tasks that should be done before merging a PR; If you want to leave a message in the codebase use FIXME
tidy [style (library)]: FAIL
removing old virtual environment
creating virtual environment at '/checkout/obj/build/venv' using 'python3.10' and 'venv'
creating virtual environment at '/checkout/obj/build/venv' using 'python3.10' and 'virtualenv'
Requirement already satisfied: pip in ./build/venv/lib/python3.10/site-packages (25.3)
linting python files
---
linting javascript files and applying suggestions
Running eslint on rustdoc JS files
info: ES-Check: there were no ES version matching errors! 🎉
typechecking javascript files
tidy: The following check failed: style (library)
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy /checkout /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo /checkout/obj/build 4 /node/bin/yarn --extra-checks=py,cpp,js,spellcheck` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1612:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1314:29
Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
Build completed unsuccessfully in 0:02:49
local time: Sun Dec 7 10:19:04 UTC 2025
network time: Sun, 07 Dec 2025 10:19:04 GMT
##[error]Process completed with exit code 1.
Interesting perf results. Let's see what happens when we specialize on array and Vec iterators...
@Urgau: Could we do another perf run please?
I hope this is ok for you @lolbinarycat since it takes from #148604, https://github.com/rust-lang/rust/pull/148604#issuecomment-3616433682 and #149694
@bors try @rust-timer queue
Awaiting bors try build completion.
@rustbot label: +S-waiting-on-perf
:hourglass: Trying commit b6110e5d14f8b2c59979d9525fa0356f21f847d1 with merge 522da8006583f67ca9cc3ef7d0a86d5092f62a59…
To cancel the try build, run the command @bors try cancel.
Workflow: https://github.com/rust-lang/rust/actions/runs/20003300074
:boom: Test timed out after 21600s
I would appreciate a Co-Authored-by field on the first commit if you could (git rebase -i then edit on that commit)
Could we run perf again? The previous attempt failed after the try build timed out.
@bors try @rust-timer queue
This pull request is already queued and waiting for a try build to finish.
:hourglass: Trying commit 9961b106a7b672d193fde1e68105568a0fb8b184 with merge ed1b0fb66582f4a21549e973103af3f8652d8b66…
To cancel the try build, run the command @bors try cancel.
Workflow: https://github.com/rust-lang/rust/actions/runs/20111120727
:sunny: Try build successful (CI)
Build commit: ed1b0fb66582f4a21549e973103af3f8652d8b66 (ed1b0fb66582f4a21549e973103af3f8652d8b66, parent: 198328ad7960b1bece0dc48496bff6c62dd5d339)
Queued ed1b0fb66582f4a21549e973103af3f8652d8b66 with parent 198328ad7960b1bece0dc48496bff6c62dd5d339, future comparison URL. There are currently 0 preceding artifacts in the queue. It will probably take at least ~1.0 hours until the benchmark run finishes.
Finished benchmarking commit (ed1b0fb66582f4a21549e973103af3f8652d8b66): comparison URL.
Overall result: ❌✅ regressions and improvements - please read the text below
Benchmarking 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.
Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.
@bors rollup=never @rustbot label: -S-waiting-on-perf +perf-regression
Instruction count
Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
- | - | 0 |
| Regressions ❌ (secondary) |
0.5% | [0.3%, 0.8%] | 3 |
| Improvements ✅ (primary) |
-0.4% | [-0.4%, -0.4%] | 1 |
| Improvements ✅ (secondary) |
-0.1% | [-0.1%, -0.0%] | 6 |
| All ❌✅ (primary) | -0.4% | [-0.4%, -0.4%] | 1 |
Max RSS (memory usage)
Results (primary 0.0%, secondary -3.5%)
A less reliable metric. May be of interest, but not used to determine the overall result above.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
3.5% | [3.5%, 3.5%] | 1 |
| Regressions ❌ (secondary) |
0.9% | [0.8%, 1.0%] | 2 |
| Improvements ✅ (primary) |
-1.1% | [-1.5%, -0.9%] | 3 |
| Improvements ✅ (secondary) |
-4.4% | [-6.9%, -1.6%] | 10 |
| All ❌✅ (primary) | 0.0% | [-1.5%, 3.5%] | 4 |
Cycles
Results (secondary 3.7%)
A less reliable metric. May be of interest, but not used to determine the overall result above.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
- | - | 0 |
| Regressions ❌ (secondary) |
4.4% | [1.8%, 7.5%] | 9 |
| Improvements ✅ (primary) |
- | - | 0 |
| Improvements ✅ (secondary) |
-2.0% | [-2.0%, -2.0%] | 1 |
| All ❌✅ (primary) | - | - | 0 |
Binary size
Results (primary -0.4%)
A less reliable metric. May be of interest, but not used to determine the overall result above.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
- | - | 0 |
| Regressions ❌ (secondary) |
- | - | 0 |
| Improvements ✅ (primary) |
-0.4% | [-1.1%, -0.1%] | 4 |
| Improvements ✅ (secondary) |
- | - | 0 |
| All ❌✅ (primary) | -0.4% | [-1.1%, -0.1%] | 4 |
Bootstrap: 471.708s -> 474.648s (0.62%) Artifact size: 389.07 MiB -> 388.75 MiB (-0.08%)