Skip to content

Sort MonoItems by span instead of DefIndex. #92323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

cjgillot
Copy link
Contributor

The codegen tests rely on items being process in the same order as they appear in the file.

Instead of sorting them by DefIndex, we should just sort them by def_span.

cc #90317.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 27, 2021
@rust-highfive
Copy link
Contributor

r? @estebank

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 27, 2021
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@pierwill
Copy link
Member

Thanks for fixing this, @cjgillot! :)

@tmiasko
Copy link
Contributor

tmiasko commented Jan 16, 2022

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

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

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 16, 2022
@bors
Copy link
Collaborator

bors commented Jan 16, 2022

⌛ Trying commit ae6ce468dd80df306640a56eebc4d170b804b259 with merge ad15d5d984b71fc84a26a3c31579c7cc4b0e1ac9...

@bors
Copy link
Collaborator

bors commented Jan 16, 2022

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

@rust-timer
Copy link
Collaborator

Queued ad15d5d984b71fc84a26a3c31579c7cc4b0e1ac9 with parent 26c06cf, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ad15d5d984b71fc84a26a3c31579c7cc4b0e1ac9): comparison url.

Summary: This change led to large relevant mixed results 🤷 in compiler performance.

  • Large improvement in instruction counts (up to -2.4% on incr-unchanged builds of deeply-nested-async)
  • Large regression in instruction counts (up to 3.7% on full builds of deeply-nested-async)

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

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jan 16, 2022
// the codegen tests and can even make item order
// unstable.
InstanceDef::Item(def) => {
def.did.as_local().map(|def_id| tcx.def_span(def_id))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe extract a single BytePos? It would reduce the number of conversions from Span to SpanData, which could be perf significant with incremental relative spans.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so it looks like we also need to include SyntaxContext to obtain "natural" order.

In that case, one thing I don't understand, what allows us to rely onSyntaxContext order? Doesn't it suffer from the similar issue as DefIndex given that we remap IDs when loading them from on disk cache, and then sort based on their values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking as blocked until we reach a strategy for SyntaxContext. Each additional use of its PartialOrd impl will make it even harder to remove.

@cjgillot cjgillot force-pushed the sort-span branch 2 times, most recently from ef3e932 to 08c8028 Compare January 16, 2022 14:21
@cjgillot
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

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

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 16, 2022
@bors
Copy link
Collaborator

bors commented Jan 16, 2022

⌛ Trying commit 08c8028afda89f06cd4fae1ae7469a10db005094 with merge 1b73506c363c317e60a0d8c2196dd03b8372cdec...

@bors
Copy link
Collaborator

bors commented Jan 16, 2022

☀️ Try build successful - checks-actions
Build commit: 1b73506c363c317e60a0d8c2196dd03b8372cdec (1b73506c363c317e60a0d8c2196dd03b8372cdec)

@rust-timer
Copy link
Collaborator

Queued 1b73506c363c317e60a0d8c2196dd03b8372cdec with parent 7be8693, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1b73506c363c317e60a0d8c2196dd03b8372cdec): comparison url.

Summary: This change led to large relevant mixed results 🤷 in compiler performance.

  • Large improvement in instruction counts (up to -2.4% on incr-unchanged builds of deeply-nested-async)
  • Large regression in instruction counts (up to 3.7% on full builds of deeply-nested-async)

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

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 16, 2022
@cjgillot cjgillot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 2, 2022
@bors
Copy link
Collaborator

bors commented Apr 13, 2022

☔ The latest upstream changes (presumably #95656) made this pull request unmergeable. Please resolve the merge conflicts.

@cjgillot
Copy link
Contributor Author

cjgillot commented Aug 6, 2022

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

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

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 6, 2022
@bors
Copy link
Collaborator

bors commented Aug 6, 2022

⌛ Trying commit e64ba94 with merge 915673e44f6d86547c2ba2e330e57a5d0060b87f...

@bors
Copy link
Collaborator

bors commented Aug 6, 2022

☀️ Try build successful - checks-actions
Build commit: 915673e44f6d86547c2ba2e330e57a5d0060b87f (915673e44f6d86547c2ba2e330e57a5d0060b87f)

@rust-timer
Copy link
Collaborator

Queued 915673e44f6d86547c2ba2e330e57a5d0060b87f with parent 44bd81d, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (915673e44f6d86547c2ba2e330e57a5d0060b87f): comparison url.

Instruction count

  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 🎉 relevant improvements found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
-1.3% -1.4% 6
All 😿🎉 (primary) N/A N/A 0

Max RSS (memory usage)

Results
  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 😿 relevant regression found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
2.4% 2.4% 1
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) N/A N/A 0

Cycles

Results
  • Primary benchmarks: 😿 relevant regression found
  • Secondary benchmarks: no relevant changes found
mean1 max count2
Regressions 😿
(primary)
2.9% 2.9% 1
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) 2.9% 2.9% 1

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 may lead to changes in compiler perf.

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

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Aug 7, 2022
@cjgillot cjgillot closed this Aug 7, 2022
@cjgillot cjgillot deleted the sort-span branch August 7, 2022 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-blocked Status: Blocked on something else such as an RFC or other implementation work. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant 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