Skip to content

perf: skip irrelevant foreign impls when building the specialization graph - #157281

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
xmakro:perf/spec-graph-skip-foreign-impls
Aug 4, 2026
Merged

perf: skip irrelevant foreign impls when building the specialization graph#157281
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
xmakro:perf/spec-graph-skip-foreign-impls

Conversation

@xmakro

@xmakroxmakro commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

View all comments

Skip foreign non-blanket impls that can't overlap any local impl when building the specialization graph. The call site showed up when profiling and this PR leads to a mean -1.5% instructions perf improvement, see #157281 (comment)

@rustbotrustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 2, 2026
@rust-log-analyzer

This comment has been minimized.

@xmakro
xmakroforce-pushed the perf/spec-graph-skip-foreign-impls branch from 290c594 to 52e8f33CompareJune 2, 2026 16:55
@xmakroxmakro changed the title Skip irrelevant foreign impls when building the specialization graphperf: Skip irrelevant foreign impls when building the specialization graphJun 3, 2026
@cjgillot

Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbotrustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 4, 2026
@rust-bors

This comment has been minimized.

rust-borsBot pushed a commit that referenced this pull request Jun 4, 2026
…<try>
perf: Skip irrelevant foreign impls when building the specialization graph
@rust-bors

rust-borsBot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

💥 Test timed out after 21600s

@xmakro
xmakroforce-pushed the perf/spec-graph-skip-foreign-impls branch from 52e8f33 to 0eef947CompareJune 5, 2026 11:51
@xmakroxmakro changed the title perf: Skip irrelevant foreign impls when building the specialization graphperf: skip irrelevant foreign impls when building the specialization graphJun 5, 2026
@xmakro

Copy link
Copy Markdown
ContributorAuthor

@cjgillot could you please retry rust-timer

@Kobzol

Copy link
Copy Markdown
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-borsBot pushed a commit that referenced this pull request Jun 10, 2026
…<try>
perf: skip irrelevant foreign impls when building the specialization graph
@rust-bors

rust-borsBot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 55fd877 (55fd87784ebf6c3bcb3d43089182c710005c85d3, parent: 485ec3fbcc12fa14ef6596dabb125ad710499c9e)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (55fd877): comparison URL.

Overall result: ✅ improvements - no action needed

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.

@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.

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
1.8%[1.8%, 1.8%]1
Improvements ✅
(primary)
-1.5%[-5.8%, -0.2%]189
Improvements ✅
(secondary)
-3.2%[-19.8%, -0.1%]133
All ❌✅ (primary)-1.5%[-5.8%, -0.2%]189

Max RSS (memory usage)

Results (primary -2.2%, secondary -2.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
--0
Improvements ✅
(primary)
-2.2%[-5.5%, -0.6%]112
Improvements ✅
(secondary)
-2.8%[-5.2%, -0.5%]69
All ❌✅ (primary)-2.2%[-5.5%, -0.6%]112

Cycles

Results (primary -4.2%, secondary -8.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
--0
Improvements ✅
(primary)
-4.2%[-7.3%, -1.8%]61
Improvements ✅
(secondary)
-8.1%[-19.2%, -1.3%]52
All ❌✅ (primary)-4.2%[-7.3%, -1.8%]61

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 517.006s -> 513.501s (-0.68%)
Artifact size: 401.43 MiB -> 400.97 MiB (-0.11%)

@rustbotrustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 10, 2026
@xmakroxmakro closed this Jun 11, 2026
@rustbotrustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 11, 2026
@xmakroxmakro reopened this Jun 11, 2026
@rustbotrustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 11, 2026
@xmakro
xmakroforce-pushed the perf/spec-graph-skip-foreign-impls branch from 0eef947 to 1ddeb9aCompareJune 11, 2026 02:39
@xmakro

Copy link
Copy Markdown
ContributorAuthor

@cjgillot would you be comfortable reviewing this PR? or maybe someone from the types team? thanks!

@xmakro

Copy link
Copy Markdown
ContributorAuthor

r? types

@rustbotrustbot added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Jun 28, 2026
@xmakro
xmakro marked this pull request as ready for review June 28, 2026 02:04
@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 28, 2026
@xmakro

Copy link
Copy Markdown
ContributorAuthor

cc @nnethercote who might be interested

@jackh726

Copy link
Copy Markdown
Member

Seems reasonable...

@bors r+

@rust-bors

rust-borsBot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 1ddeb9a has been approved by jackh726

It is now in the queue for this repository.

@rust-borsrust-borsBot 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-review Status: Awaiting review from the assignee but also interested parties. labels Aug 4, 2026
@JonathanBrouwer

This comment was marked as resolved.

@rust-bors

This comment was marked as resolved.

@JonathanBrouwer

This comment was marked as resolved.

@rust-bors

This comment was marked as resolved.

@JonathanBrouwer

This comment was marked as resolved.

@rust-bors

This comment was marked as resolved.

@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors rollup=iffy
Including this in a special perf-sensitive rollup

rust-borsBot pushed a commit that referenced this pull request Aug 4, 2026
…uwer
Rollup of 10 perf-sensitive pull requests
Successful merges:
- #157281 (perf: skip irrelevant foreign impls when building the specialization graph)
- #159403 (Next steps for FnDef binder changes (instantiate most FnDef binders))
- #159763 (Optimize crate resolution for large workspace)
- #160033 (Speed up `EverInitializedPlaces`)
- #160268 (perf: store the fulfillment engine inline in ObligationCtxt)
- #160317 (perf: Cache already-checked types in the privacy visitor)
- #160399 (interpret: skip deref-projection validity checks when they are not needed)
- #160451 (Deduplicate target and host filesearch)
- #160453 (Add fast path to `escape_string_symbol`)
- #160454 (Add offload guard flags to typeck to prevent perf regressions)
@rust-bors
rust-borsBot merged commit e18f209 into rust-lang:mainAug 4, 2026
12 checks passed
rust-timer added a commit that referenced this pull request Aug 4, 2026
Rollup merge of #157281 - xmakro:perf/spec-graph-skip-foreign-impls, r=jackh726
perf: skip irrelevant foreign impls when building the specialization graph
Skip foreign non-blanket impls that can't overlap any local impl when building the specialization graph. The call site showed up when profiling and this PR leads to a mean -1.5% instructions perf improvement, see #157281 (comment)
@rustbotrustbot added this to the 1.99.0 milestone Aug 4, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member

Verifying that actual perf results after merge match expected results
@rust-timer build 6e2e027

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (6e2e027): comparison URL.

Overall result: ✅ improvements - no action needed

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.

@bors rollup=never rustc-perf
@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.

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
--0
Improvements ✅
(primary)
-1.5%[-6.1%, -0.2%]209
Improvements ✅
(secondary)
-3.2%[-19.7%, -0.1%]137
All ❌✅ (primary)-1.5%[-6.1%, -0.2%]209

Max RSS (memory usage)

Results (primary -2.0%, secondary -2.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

meanrangecount
Regressions ❌
(primary)
1.4%[1.0%, 1.9%]2
Regressions ❌
(secondary)
2.4%[0.7%, 4.2%]2
Improvements ✅
(primary)
-2.0%[-4.1%, -0.4%]138
Improvements ✅
(secondary)
-2.7%[-6.1%, -0.4%]83
All ❌✅ (primary)-2.0%[-4.1%, 1.9%]140

Cycles

Results (primary -3.5%, secondary -6.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

meanrangecount
Regressions ❌
(primary)
0.6%[0.6%, 0.6%]1
Regressions ❌
(secondary)
0.8%[0.6%, 1.1%]3
Improvements ✅
(primary)
-3.5%[-7.6%, -0.7%]85
Improvements ✅
(secondary)
-6.7%[-20.4%, -0.5%]70
All ❌✅ (primary)-3.5%[-7.6%, 0.6%]86

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 489.577s -> 487.42s (-0.44%)
Artifact size: 390.24 MiB -> 390.39 MiB (0.04%)

WhySoBad pushed a commit to WhySoBad/miri that referenced this pull request Aug 5, 2026
…r=jackh726
perf: skip irrelevant foreign impls when building the specialization graph
Skip foreign non-blanket impls that can't overlap any local impl when building the specialization graph. The call site showed up when profiling and this PR leads to a mean -1.5% instructions perf improvement, see rust-lang/rust#157281 (comment)
WhySoBad pushed a commit to WhySoBad/miri that referenced this pull request Aug 5, 2026
…uwer
Rollup of 10 perf-sensitive pull requests
Successful merges:
- rust-lang/rust#157281 (perf: skip irrelevant foreign impls when building the specialization graph)
- rust-lang/rust#159403 (Next steps for FnDef binder changes (instantiate most FnDef binders))
- rust-lang/rust#159763 (Optimize crate resolution for large workspace)
- rust-lang/rust#160033 (Speed up `EverInitializedPlaces`)
- rust-lang/rust#160268 (perf: store the fulfillment engine inline in ObligationCtxt)
- rust-lang/rust#160317 (perf: Cache already-checked types in the privacy visitor)
- rust-lang/rust#160399 (interpret: skip deref-projection validity checks when they are not needed)
- rust-lang/rust#160451 (Deduplicate target and host filesearch)
- rust-lang/rust#160453 (Add fast path to `escape_string_symbol`)
- rust-lang/rust#160454 (Add offload guard flags to typeck to prevent perf regressions)
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Aug 17, 2026
…uwer
Rollup of 10 perf-sensitive pull requests
Successful merges:
- rust-lang/rust#157281 (perf: skip irrelevant foreign impls when building the specialization graph)
- rust-lang/rust#159403 (Next steps for FnDef binder changes (instantiate most FnDef binders))
- rust-lang/rust#159763 (Optimize crate resolution for large workspace)
- rust-lang/rust#160033 (Speed up `EverInitializedPlaces`)
- rust-lang/rust#160268 (perf: store the fulfillment engine inline in ObligationCtxt)
- rust-lang/rust#160317 (perf: Cache already-checked types in the privacy visitor)
- rust-lang/rust#160399 (interpret: skip deref-projection validity checks when they are not needed)
- rust-lang/rust#160451 (Deduplicate target and host filesearch)
- rust-lang/rust#160453 (Add fast path to `escape_string_symbol`)
- rust-lang/rust#160454 (Add offload guard flags to typeck to prevent perf regressions)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.T-typesRelevant to the types team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@xmakro@rust-log-analyzer@cjgillot@rust-timer@Kobzol@jackh726@JonathanBrouwer@rustbot