Skip to content

Use Vec extend instead of repeated pushes on several places - #91042

Merged
bors merged 1 commit into
rust-lang:masterfrom
Kobzol:vec-extend-cleanup
Dec 9, 2021
Merged

Use Vec extend instead of repeated pushes on several places#91042
bors merged 1 commit into
rust-lang:masterfrom
Kobzol:vec-extend-cleanup

Conversation

@Kobzol

Copy link
Copy Markdown
Member

Inspired by #90813, I tried to use a simple regex (for .*in.*\{\n.*push\(.*\);\n\s+}) to search for more places that would use Vec::push in a loop and replace them with Vec::extend.

These probably won't have as much perf. impact as the original PR (if any), but it would probably be better to do a perf run to see if there are not any regressions.

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @nagisa

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 19, 2021
@jyn514

Copy link
Copy Markdown
Member

@bors try @rust-timer queue

@rust-timer

Copy link
Copy Markdown
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbotrustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 19, 2021
@bors

bors commented Nov 19, 2021

Copy link
Copy Markdown
Collaborator

⌛ Trying commit ad94a04fa16f53a0ac69983b8e7d6bf9640453a1 with merge 76d592791c8d5353c733921c2564ffb0b6b2ed3b...

@jyn514jyn514 added I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Nov 19, 2021
Comment threadcompiler/rustc_builtin_macros/src/format.rs Outdated
Comment threadcompiler/rustc_builtin_macros/src/format.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@nagisa

Copy link
Copy Markdown
Member

@bors try @rust-timer queue

@rust-timer

Copy link
Copy Markdown
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbotrustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 19, 2021
@bors

bors commented Nov 19, 2021

Copy link
Copy Markdown
Collaborator

⌛ Trying commit 3e9d1b944e9b6d599415446bf0ffc3dfe1e32718 with merge 826bfd4f40a8dcd4947f74103178fb991029a322...

@bors

bors commented Nov 20, 2021

Copy link
Copy Markdown
Collaborator

☀️ Try build successful - checks-actions
Build commit: 826bfd4f40a8dcd4947f74103178fb991029a322 (826bfd4f40a8dcd4947f74103178fb991029a322)

@rust-timer

Copy link
Copy Markdown
Collaborator

Queued 826bfd4f40a8dcd4947f74103178fb991029a322 with parent a77da2d, future comparison URL.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (826bfd4f40a8dcd4947f74103178fb991029a322): comparison url.

Summary: This change led to very large relevant regressions 😿 in compiler performance.

  • Very large regression in instruction counts (up to 5.3% on incr-unchanged builds of inflate)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking 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 led to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf +perf-regression

@rustbotrustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Nov 20, 2021
@Kobzol

Copy link
Copy Markdown
MemberAuthor

Hmm, I could investigate the regression, but since it seems that there are no big improvements either, I wonder if it's worth it to do these changes at all?

@jyn514

Copy link
Copy Markdown
Member

@Kobzol FYI perf has been very unreliable lately, so this doesn't necessarily mean your change is slower. There's a Zulip thread about it somewhere.

Comment threadcompiler/rustc_builtin_macros/src/format.rs Outdated
@nagisa

Copy link
Copy Markdown
Member

r=me once the conflicts are resolved.

@nagisanagisa removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 8, 2021
@nagisanagisa added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Dec 8, 2021
@Kobzol

Copy link
Copy Markdown
MemberAuthor

@nagisa I kept only the less controversial changes and rebased. (I don't have permissions to r=you though I suppose)

@nagisa

Copy link
Copy Markdown
Member

@bors r+ rollup

Thanks!

@bors

bors commented Dec 8, 2021

Copy link
Copy Markdown
Collaborator

📌 Commit 883d0a7 has been approved by nagisa

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 8, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 9, 2021
…askrgr
Rollup of 5 pull requests
Successful merges:
- rust-lang#91042 (Use Vec extend instead of repeated pushes on several places)
- rust-lang#91476 (Improve 'cannot contain emoji' error.)
- rust-lang#91568 (Pretty print break and continue without redundant space)
- rust-lang#91645 (Implement `core::future::join!`)
- rust-lang#91666 (update Miri)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 9, 2021
Use Vec extend instead of repeated pushes on several places
Inspired by rust-lang#90813, I tried to use a simple regex (`for .*in.*\{\n.*push\(.*\);\n\s+}`) to search for more places that would use `Vec::push` in a loop and replace them with `Vec::extend`.
These probably won't have as much perf. impact as the original PR (if any), but it would probably be better to do a perf run to see if there are not any regressions.
@bors
bors merged commit 793648a into rust-lang:masterDec 9, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 9, 2021
…askrgr
Rollup of 6 pull requests
Successful merges:
- rust-lang#87599 (Implement concat_bytes!)
- rust-lang#89999 (Update std::env::temp_dir to use GetTempPath2 on Windows when available.)
- rust-lang#90796 (Remove the reg_thumb register class for asm! on ARM)
- rust-lang#91042 (Use Vec extend instead of repeated pushes on several places)
- rust-lang#91634 (Do not attempt to suggest help for overly malformed struct/function call)
- rust-lang#91685 (Install llvm tools to sysroot when assembling local toolchain)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@rustbotrustbot added this to the 1.59.0 milestone Dec 9, 2021
@Kobzol
Kobzol deleted the vec-extend-cleanup branch December 9, 2021 07:10
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I-compiletimeIssue: Problems and improvements with respect to compile times.perf-regressionPerformance regression.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@Kobzol@rust-highfive@jyn514@rust-timer@bors@rust-log-analyzer@nagisa@the8472@rustbot