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

Assert that global cache values are stable on insertion #110473

Closed

Conversation

compiler-errors
Copy link
Member

Let's make sure not to overwrite cache values with new values in, e.g., the evaluation cache and selection cache. I haven't found this being triggered in practice, but if we ever did, that'd be incredibly interesting to study.

There was a FIXME that says that we should be using HashMapExt::insert_same, but it turns out that we can't (cc @Zoxc in #50507), because it turns out that these cache entries are only equal modulo dep node index. But we don't need to use that particular method to protect against collisions in these caches, since we can just ignore the dep node. So instead of using that, let's just check that the values are the same.

@rustbot
Copy link
Collaborator

rustbot commented Apr 18, 2023

r? @WaffleLapkin

(rustbot has picked a reviewer for you, use r? to override)

@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. labels Apr 18, 2023
@Zoxc
Copy link
Contributor

Zoxc commented Apr 18, 2023

This only partially addresses the FIXME, given that the DepNodeIndex can still differ. The relevant question is why the same value ends up having different dependencies? If one of them are missing dependencies, that can lead to incremental bugs.

@compiler-errors
Copy link
Member Author

compiler-errors commented Apr 18, 2023

Ah, @SparrowLii's #100987 seems to suggest a reason for the instability of the DepNodeIndex part of the cache value?

I'm mostly interested in the cached EvaluationResult here staying stable. I'm happy to add the FIXME back though because of your concern, or at least clarify the FIXME though.

@compiler-errors
Copy link
Member Author

Lol, oh, didn't read down-thread enough to see you commented on that. Oh well. I'll update the FIXME anyways.

Copy link
Member

@WaffleLapkin WaffleLapkin left a comment

Choose a reason for hiding this comment

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

This looks good to me. Do we need a perf run? Adding an assertion to the cache seems potentially damaging it.

@compiler-errors
Copy link
Member Author

@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 Apr 18, 2023
@bors
Copy link
Contributor

bors commented Apr 18, 2023

⌛ Trying commit 6b9862d with merge 6fedcc8c38319f932c1e095b4e13a5cb1268253c...

@compiler-errors
Copy link
Member Author

@rust-timer queue 6fedcc8c38319f932c1e095b4e13a5cb1268253c

@rust-timer

This comment has been minimized.

@compiler-errors
Copy link
Member Author

@bors try

@bors
Copy link
Contributor

bors commented Apr 18, 2023

⌛ Trying commit 6b9862d with merge dc41b88ee80166179217d22575571a4b01efdc00...

@compiler-errors
Copy link
Member Author

whoops wrong rust-timer command, maybe my try build from last night did succeed

@rust-timer build 6fedcc8c38319f932c1e095b4e13a5cb1268253c

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6fedcc8c38319f932c1e095b4e13a5cb1268253c): comparison URL.

Overall result: ❌ regressions - ACTION NEEDED

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

Warning ⚠: The following benchmark(s) failed to build:

  • diesel-1.4.8

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)
1.7% [0.7%, 2.9%] 4
Regressions ❌
(secondary)
4.9% [0.2%, 8.1%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.7% [0.7%, 2.9%] 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)
1.8% [1.8%, 1.8%] 1
Regressions ❌
(secondary)
2.3% [1.6%, 2.9%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.5% [-3.5%, -3.5%] 1
All ❌✅ (primary) 1.8% [1.8%, 1.8%] 1

Cycles

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

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Apr 18, 2023
@compiler-errors
Copy link
Member Author

Warning warning: The following benchmark(s) failed to build:
diesel-1.4.8

this sucks lol

@bors
Copy link
Contributor

bors commented Apr 18, 2023

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

@compiler-errors compiler-errors 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 Apr 19, 2023
@Zoxc
Copy link
Contributor

Zoxc commented Apr 25, 2023

Why was this closed? The failure seems like an existing bug to me?

@compiler-errors
Copy link
Member Author

That's a cache conflict in the InferCtxt-local cache used by evaluation.

It's probably not a bug worth solving, since it's likely only going to happen on overflow anyways, when a goal is later re-evaluated without hitting overflow because the depth is lower or something.

@Zoxc
Copy link
Contributor

Zoxc commented Apr 25, 2023

That does seem like something that could lead to incremental compilation bugs.

@compiler-errors compiler-errors deleted the stable-cache branch August 11, 2023 20:19
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) perf-regression Performance regression. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants