Skip to content
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

Reduce the cost of loading all built-ins targets #95202

Merged
merged 4 commits into from
Apr 3, 2022

Conversation

Urgau
Copy link
Member

@Urgau Urgau commented Mar 22, 2022

This PR started by measuring the exact slowdown of checking of well known conditional values.
Than this PR implemented some technics to reduce the cost of loading all built-ins targets.

cf. #82450 (comment)

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 22, 2022
@rust-log-analyzer

This comment has been minimized.

@lqd
Copy link
Member

lqd commented Mar 22, 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 Mar 22, 2022
@bors
Copy link
Contributor

bors commented Mar 22, 2022

⌛ Trying commit aeadc42389613ae25e868809e26100fa960da068 with merge f1bad32f32f5ed8240872cb387d09a3635f62297...

@bors
Copy link
Contributor

bors commented Mar 22, 2022

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

@rust-timer
Copy link
Collaborator

Queued f1bad32f32f5ed8240872cb387d09a3635f62297 with parent b9c4067, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f1bad32f32f5ed8240872cb387d09a3635f62297): comparison url.

Summary: This benchmark run shows 68 relevant regressions 😿 to instruction counts.

  • Arithmetic mean of relevant regressions: 1.4%
  • Largest regression in instruction counts: 4.0% on full builds of helloworld check

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. 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. labels Mar 22, 2022
@Urgau
Copy link
Member Author

Urgau commented Mar 22, 2022

@petrochenkov Do you want me to try with Cow<String> instead of String for the targets ? or something else ?

@petrochenkov petrochenkov self-assigned this Mar 25, 2022
@petrochenkov
Copy link
Contributor

@Urgau
Yes, non-empty Strings are the main blocker for constification of target specs, but there may be other issues.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 25, 2022
@Urgau
Copy link
Member Author

Urgau commented Mar 25, 2022

Before measuring the cost (hopefully negative) of replacing every String by Cow<String>, I would be good to check whenever it's actually significative. I just push a commit who disable the checking but NOT the loading of values (targets, ...).

@bjorn3
Copy link
Member

bjorn3 commented Mar 25, 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 Mar 25, 2022
@bors
Copy link
Contributor

bors commented Mar 25, 2022

⌛ Trying commit 93a4d854318dcc9c758403213ebb77be98eaa02c with merge f2bca08ebf42b573bcacc3ae5a8dacabb8f03268...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Mar 25, 2022

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

@rust-timer
Copy link
Collaborator

Queued f2bca08ebf42b573bcacc3ae5a8dacabb8f03268 with parent 903427b, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f2bca08ebf42b573bcacc3ae5a8dacabb8f03268): comparison url.

Summary: This benchmark run shows 68 relevant regressions 😿 to instruction counts.

  • Arithmetic mean of relevant regressions: 1.5%
  • Largest regression in instruction counts: 4.2% on full builds of helloworld check

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 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. labels Mar 26, 2022
@petrochenkov
Copy link
Contributor

The PR's title and description need to be updated.
Also CI is failing.
@bors rollup=maybe

@Urgau Urgau force-pushed the check-cfg-perf-well-known-values branch from 1424502 to 2191d2a Compare April 3, 2022 17:11
@Urgau Urgau changed the title [PERF] Always enable checking of well known conditional values Reduce cost of creating built-ins targets Apr 3, 2022
@Urgau Urgau changed the title Reduce cost of creating built-ins targets Reduce the cost of loading all built-ins targets Apr 3, 2022
@Urgau Urgau force-pushed the check-cfg-perf-well-known-values branch from 2191d2a to 303611c Compare April 3, 2022 17:35
@petrochenkov
Copy link
Contributor

Unit tests in rustc_target are failing.
@rustbot author

@@ -1107,6 +1104,8 @@ impl HasTargetSpec for Target {
}
}

type StaticCow<T> = Cow<'static, T>;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this adds much. It only saves 2 characters.

Copy link
Contributor

Choose a reason for hiding this comment

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

I asked to add it in #95202 (comment) because it looks less noisy due to removing punctuation like ' and , even if it's only slightly shorter. (Not a strong opinion.)

@Urgau Urgau force-pushed the check-cfg-perf-well-known-values branch from 303611c to 1a1f5b8 Compare April 3, 2022 19:33
@Urgau
Copy link
Member Author

Urgau commented Apr 3, 2022

Review comments addressed or responded. Commits squashed to only 4, but can squash to only 1 if you prefer.
Title and PR description also addressed. Also fix all of the failing unit tests (incorrectly removed to_string() when serializing pointer_width).

@rustbot ready

@rustbot rustbot 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 Apr 3, 2022
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Apr 3, 2022

📌 Commit 1a1f5b8 has been approved by petrochenkov

@bors bors 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 Apr 3, 2022
@bors
Copy link
Contributor

bors commented Apr 3, 2022

⌛ Testing commit 1a1f5b8 with merge 8a8b80634e8c439c8b36e3b3729a5094606ae9cd...

@Dylan-DPC
Copy link
Member

@bors retry (yield to rollup containing this pr)

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 3, 2022
Rollup of 5 pull requests

Successful merges:

 - rust-lang#95202 (Reduce the cost of loading all built-ins targets)
 - rust-lang#95553 (Don't emit non-asm contents error for naked function composed of errors)
 - rust-lang#95613 (Fix rustdoc attribute display)
 - rust-lang#95617 (Fix &mut invalidation in ptr::swap doctest)
 - rust-lang#95618 (core: document that the align_of* functions return the alignment in bytes)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.