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

Always evaluate free constants and statics, even if previous errors occurred #121087

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Feb 14, 2024

work towards #79738

We will need to evaluate static items before the definitions.freeze() below, as we will start creating new DefIds (for nested allocations) within the eval_static_initializer query.

But even without that motivation, this is a good change. Hard errors should always be reported and not silenced if other errors happened earlier.

@rustbot
Copy link
Collaborator

rustbot commented Feb 14, 2024

r? @lcnr

rustbot has assigned @lcnr.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added 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. labels Feb 14, 2024
@rustbot
Copy link
Collaborator

rustbot commented Feb 14, 2024

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Feb 14, 2024

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Feb 14, 2024

The Miri subtree was changed

cc @rust-lang/miri

@rust-log-analyzer

This comment has been minimized.

Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

r=me after nits + CI

compiler/rustc_lint/src/builtin.rs Show resolved Hide resolved
static BOO: &mut Foo<()> = &mut Foo(());
//~^ ERROR encountered mutable pointer in final value of static

// interior mutability is fine
Copy link
Contributor

Choose a reason for hiding this comment

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

outdated comment, this test generally feels somewhat useless rn, given that its behavior doesn't depend on -Zunleash-the-miri-inside-of-you afaict?

Copy link
Member

Choose a reason for hiding this comment

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

stderr has a bunch of "skipping check that does not even have a feature gate", so I think it does depend on the unleash flag.

@oli-obk oli-obk force-pushed the eager_const_failures branch 2 times, most recently from 0bb9b2b to 3f88472 Compare February 15, 2024 11:45
@rust-log-analyzer

This comment has been minimized.

Comment on lines 249 to +252
let secondary_errors = mem::take(&mut self.secondary_errors);
if self.error_emitted.is_none() {
for error in secondary_errors {
error.emit();
self.error_emitted = Some(error.emit());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@RalfJung found the issue that caused us to const eval even though there were const qualif errors 🙈

@bors
Copy link
Contributor

bors commented Feb 15, 2024

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

@rust-log-analyzer

This comment has been minimized.

@bjorn3
Copy link
Member

bjorn3 commented Feb 15, 2024

as we will start creating new DefIds (for nested allocations) within the eval_static_initializer query.

Wouldn't it be possible to represent the id of nested statics as a pair of "def id of containing static" and "index of this nested static"?

@oli-obk
Copy link
Contributor Author

oli-obk commented Feb 15, 2024

Wouldn't it be possible to represent the id of nested statics as a pair of "def id of containing static" and "index of this nested static"?

yes, but that just makes everything more complex, as then everything needs to handle this special case. I tried it, and it's annoying to get right. Just generating a new static per nested allocation was significantly simpler.

@oli-obk
Copy link
Contributor Author

oli-obk commented Feb 15, 2024

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Feb 15, 2024

📌 Commit 7770df0 has been approved by lcnr

It is now in the queue for this repository.

@bors bors merged commit cce6a6e into rust-lang:master Feb 20, 2024
12 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Feb 20, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (cce6a6e): comparison URL.

Overall result: ❌ regressions - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

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

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.8% [0.4%, 2.0%] 4
Regressions ❌
(secondary)
1.0% [0.3%, 5.2%] 11
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.8% [0.4%, 2.0%] 4

Max RSS (memory usage)

Results

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)
9.9% [1.5%, 15.6%] 22
Improvements ✅
(primary)
-3.3% [-4.0%, -2.4%] 3
Improvements ✅
(secondary)
-3.2% [-5.3%, -1.4%] 3
All ❌✅ (primary) -3.3% [-4.0%, -2.4%] 3

Cycles

Results

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)
3.3% [2.2%, 4.1%] 7
Regressions ❌
(secondary)
3.2% [2.8%, 3.7%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.3% [2.2%, 4.1%] 7

Binary size

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

Bootstrap: 641.541s -> 639.567s (-0.31%)
Artifact size: 308.58 MiB -> 310.63 MiB (0.66%)

@rustbot rustbot added the perf-regression Performance regression. label Feb 20, 2024
@oli-obk oli-obk deleted the eager_const_failures branch February 20, 2024 12:41
@oli-obk
Copy link
Contributor Author

oli-obk commented Feb 20, 2024

Looking into the regressions. They are unintended

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 21, 2024
…ion, r=<try>

Avoid some unnecessary query invocations.

Specifically this inlines `const_eval_poly` and avoids computing the generic params, the param env, normalizing the param env and erasing lifetimes on everything.

should fix the perf regression from rust-lang#121087
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 22, 2024
…ion, r=<try>

Avoid some unnecessary query invocations.

Specifically this inlines `const_eval_poly` and avoids computing the generic params, the param env, normalizing the param env and erasing lifetimes on everything.

should fix the perf regression from rust-lang#121087
@oli-obk
Copy link
Contributor Author

oli-obk commented Feb 23, 2024

@rustbot label: +perf-regression-triaged

I fixed the libc regression in #121387

The other regressions' detailed view actually shows improvements instead of a regression, and the benchmarks themselves have been flaky on the same scale as they were affected here, so I'm guessing it's not related

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Feb 23, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 26, 2024
…ion, r=<try>

Avoid some unnecessary query invocations.

Specifically this inlines `const_eval_poly` and avoids computing the generic params, the param env, normalizing the param env and erasing lifetimes on everything.

should fix the perf regression from rust-lang#121087
flip1995 pushed a commit to flip1995/rust that referenced this pull request Feb 26, 2024
Always evaluate free constants and statics, even if previous errors occurred

work towards rust-lang#79738

We will need to evaluate static items before the `definitions.freeze()` below, as we will start creating new `DefId`s (for nested allocations) within the `eval_static_initializer` query.

But even without that motivation, this is a good change. Hard errors should always be reported and not silenced if other errors happened earlier.
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 26, 2024
…ion, r=lcnr

Avoid some unnecessary query invocations.

Specifically this inlines `const_eval_poly` and avoids computing the generic params, the param env, normalizing the param env and erasing lifetimes on everything.

should fix the perf regression from rust-lang#121087
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Mar 29, 2024
Avoid some unnecessary query invocations.

Specifically this inlines `const_eval_poly` and avoids computing the generic params, the param env, normalizing the param env and erasing lifetimes on everything.

should fix the perf regression from rust-lang/rust#121087
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants