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

nightly feature tracking: get rid of the per-feature bool fields #132027

Merged
merged 5 commits into from
Oct 23, 2024

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Oct 22, 2024

The struct Features that tracks which features are enabled has a ton of public bool-typed fields that are basically caching the result of looking up the corresponding feature in enabled_lang_features. Having public fields with an invariant is not great, so at least they should be made private. However, it turns out caching these lookups is actually not worth it, so this PR just entirely gets rid of these fields. (The alternative would be to make them private and have a method for each of them to expose them in a read-only way. Most of the diff of this PR would be the same in that case.)

r? @nnethercote

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Oct 22, 2024
@rustbot
Copy link
Collaborator

rustbot commented Oct 22, 2024

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

HIR ty lowering was modified

cc @fmease

Some changes occurred in exhaustiveness checking

cc @Nadrieril

Some changes occurred in const_evaluatable.rs

cc @BoxyUwU

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred in src/librustdoc/clean/types.rs

cc @camelid

These commits modify compiler targets.
(See the Target Tier Policy.)

Some changes occurred in match checking

cc @Nadrieril

changes to the core type system

cc @compiler-errors, @lcnr

Some changes occurred in match lowering

cc @Nadrieril

Some changes occurred in rustc_ty_utils::consts.rs

cc @BoxyUwU

@RalfJung RalfJung force-pushed the lang-feature-bool-fields branch from 16e611f to dd8850b Compare October 22, 2024 14:40
Copy link
Contributor

@nnethercote nnethercote left a comment

Choose a reason for hiding this comment

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

A nice simplification. Just a few minor comments.

compiler/rustc_feature/src/builtin_attrs.rs Outdated Show resolved Hide resolved
compiler/rustc_feature/src/unstable.rs Outdated Show resolved Hide resolved
compiler/rustc_feature/src/unstable.rs Show resolved Hide resolved
compiler/rustc_feature/src/unstable.rs Show resolved Hide resolved
compiler/rustc_codegen_ssa/src/target_features.rs Outdated Show resolved Hide resolved
@nnethercote
Copy link
Contributor

Let's do another perf run, just to be sure:

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 22, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 22, 2024
…=<try>

nightly feature tracking: get rid of the per-feature bool fields

The `struct Features` that tracks which features are enabled has a ton of public `bool`-typed fields that are basically caching the result of looking up the corresponding feature in `enabled_lang_features`. Having public fields with an invariant is not great, so at least they should be made private. However, it turns out caching these lookups is actually [not worth it](rust-lang#131321 (comment)), so this PR just entirely gets rid of these fields. (The alternative would be to make them private and have a method for each of them to expose them in a read-only way. Most of the diff of this PR would be the same in that case.)

r? `@nnethercote`
@bors
Copy link
Contributor

bors commented Oct 22, 2024

⌛ Trying commit dd8850b with merge 740f801...

@bors
Copy link
Contributor

bors commented Oct 22, 2024

☀️ Try build successful - checks-actions
Build commit: 740f801 (740f801072bbece1059248b3173d1ea8d7da6435)

@rust-timer

This comment has been minimized.

@RalfJung RalfJung force-pushed the lang-feature-bool-fields branch from dd8850b to 6de4afd Compare October 23, 2024 06:31
@RalfJung RalfJung force-pushed the lang-feature-bool-fields branch from 5cdf91a to 4463885 Compare October 23, 2024 08:14
@RalfJung
Copy link
Member Author

This PR is very conflict-heavy so I'd appreciate if we could delegate minor improvements to a future PR.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (740f801): comparison URL.

Overall result: ❌ regressions - please read the text below

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.

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-perf +perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.3% [0.1%, 2.1%] 11
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 2.1%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.1% [2.1%, 2.1%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.1% [2.1%, 2.1%] 1

Cycles

Results (secondary -2.6%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.6% [-2.6%, -2.6%] 1
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 780.615s -> 779.786s (-0.11%)
Artifact size: 333.63 MiB -> 333.61 MiB (-0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 23, 2024
@nnethercote
Copy link
Contributor

The deep-vector regression is probably noise. The match-stress ones are more likely to be real (they were seen, very slightly, in #131321) but they are tiny and it's a stress test so doesn't matter.

@rustbot label: +perf-regression-triaged
@bors r+

@bors
Copy link
Contributor

bors commented Oct 23, 2024

📌 Commit 4463885 has been approved by nnethercote

It is now in the queue for this repository.

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Oct 23, 2024
@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 23, 2024
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Oct 23, 2024
@bors
Copy link
Contributor

bors commented Oct 23, 2024

⌛ Testing commit 4463885 with merge be01dab...

@bors
Copy link
Contributor

bors commented Oct 23, 2024

☀️ Test successful - checks-actions
Approved by: nnethercote
Pushing be01dab to master...

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (be01dab): comparison URL.

Overall result: ❌ regressions - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
1.2% [1.1%, 1.2%] 4
Regressions ❌
(secondary)
0.5% [0.1%, 1.1%] 34
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.2% [1.1%, 1.2%] 4

Max RSS (memory usage)

Results (primary 1.0%, secondary 2.3%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.0% [0.9%, 1.3%] 4
Regressions ❌
(secondary)
2.3% [2.1%, 2.5%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.0% [0.9%, 1.3%] 4

Cycles

Results (secondary 2.5%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.5% [2.0%, 3.0%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 781.646s -> 780.494s (-0.15%)
Artifact size: 333.65 MiB -> 333.63 MiB (-0.01%)

@RalfJung
Copy link
Member Author

Hm, that's a bit more than we expected, isn't it?
Should we bring back the bool fields internally to speed up these functions? (But keep the functions)

@nnethercote
Copy link
Contributor

Occasionally we get a weird results where lots of benchmarks get a little worse, and then things go back on the next merge. This looks like such a case. Especially given that there were two previous perf runs (one here, one in #131321) that looked better. So I think nothing needs to be done here.

@rustbot label: +perf-regression-triaged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants