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

Disable the evaluation cache when in intercrate mode #88994

Merged
merged 1 commit into from
Sep 18, 2021

Conversation

Aaron1011
Copy link
Member

It's possible to use the same InferCtxt with both
an intercrate and non-intercrate SelectionContext. However,
the local (inferctxt) evaluation cache is not aware of this
distinction, so this kind of InferCtxt re-use will pollute
the cache wth bad results.

This commit avoids the issue by disabling the evaluation cache
entirely during intercrate mode.

It's possible to use the same `InferCtxt` with both
an intercrate and non-intercrate `SelectionContext`. However,
the local (inferctxt) evaluation cache is not aware of this
distinction, so this kind of `InferCtxt` re-use will pollute
the cache wth bad results.

This commit avoids the issue by disabling the evaluation cache
entirely during intercrate mode.
@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(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 Sep 15, 2021
@Aaron1011
Copy link
Member 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 Sep 15, 2021
@bors
Copy link
Contributor

bors commented Sep 15, 2021

⌛ Trying commit 6d1f4d2 with merge ce935c6cd218f340d811819c3783652b0070319a...

@bors
Copy link
Contributor

bors commented Sep 16, 2021

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

@rust-timer
Copy link
Collaborator

Queued ce935c6cd218f340d811819c3783652b0070319a with parent 2c7bc5e, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ce935c6cd218f340d811819c3783652b0070319a): comparison url.

Summary: This change led to small relevant improvements 🎉 in compiler performance.

  • Small improvement in instruction counts (up to -0.3% on incr-patched: Job builds of regex)

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.

@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 Sep 16, 2021
@petrochenkov
Copy link
Contributor

r? @rust-lang/wg-traits

@petrochenkov
Copy link
Contributor

r? @nikomatsakis
(I don't know who else is active in this area.)

@jackh726
Copy link
Member

@bors r+
Its obviously "correct" to just not cache. Given there's not a perf regression here, this should be fine.

I'd like a test, but given it's a big repro, I'm not blocking on that.

The other PR (#88993) is less "obviously correct" and imo "more complicated" (though not really).

r? @jackh726

(Also, for the future, its rust-lang/traits for highfive)

@bors
Copy link
Contributor

bors commented Sep 17, 2021

📌 Commit 6d1f4d2 has been approved by jackh726

@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 Sep 17, 2021
@Mark-Simulacrum Mark-Simulacrum added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Sep 17, 2021
@Mark-Simulacrum
Copy link
Member

beta-nominating as a fix for #88969, which is a beta regression

@bors
Copy link
Contributor

bors commented Sep 18, 2021

⌛ Testing commit 6d1f4d2 with merge 35c8f26...

@bors
Copy link
Contributor

bors commented Sep 18, 2021

☀️ Test successful - checks-actions
Approved by: jackh726
Pushing 35c8f26 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 18, 2021
@bors bors merged commit 35c8f26 into rust-lang:master Sep 18, 2021
@rustbot rustbot added this to the 1.57.0 milestone Sep 18, 2021
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (35c8f26): comparison url.

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

  • Moderate improvement in instruction counts (up to -0.9% on incr-full builds of coercions)
  • Small regression in instruction counts (up to 0.4% on full builds of clap-rs)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

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

@rustbot rustbot added the perf-regression Performance regression. label Sep 19, 2021
@jackh726
Copy link
Member

jackh726 commented Sep 19, 2021

Perf regression is small enough and, given that this is a correctness fix, ultimately okay.

@m-ou-se
Copy link
Member

m-ou-se commented Sep 20, 2021

This PR seems to be the cause of #89119, somehow.

Aaron1011 added a commit to Aaron1011/rust that referenced this pull request Sep 20, 2021
Fixes rust-lang#88969

It appears that *just* disabling the evaluation cache (in rust-lang#88994)
leads to other issues involving intercrate mode caching. I suspect
that since we now always end up performing the full evaluation
in intercrate mode, we end up 'polluting' the candidate and projection
caches with results that depend on being in intercrate mode in some way.
Previously, we might have hit a cached evaluation (stored during
non-intercrate mode), and skipped doing this extra work in
intercrate mode.

The whole situation with intercrate mode caching is turning into
a mess. Ideally, we would remove intercrate mode entirely - however,
this might require waiting on Chalk.
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 21, 2021
…jackh726

Don't use projection cache or candidate cache in intercrate mode

Fixes rust-lang#88969

It appears that *just* disabling the evaluation cache (in rust-lang#88994)
leads to other issues involving intercrate mode caching. I suspect
that since we now always end up performing the full evaluation
in intercrate mode, we end up 'polluting' the candidate and projection
caches with results that depend on being in intercrate mode in some way.
Previously, we might have hit a cached evaluation (stored during
non-intercrate mode), and skipped doing this extra work in
intercrate mode.

The whole situation with intercrate mode caching is turning into
a mess. Ideally, we would remove intercrate mode entirely - however,
this might require waiting on Chalk.
@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 22, 2021
@apiraino
Copy link
Contributor

Beta backport accepted as per compiler team on Zulip

@rustbot label +beta-accepted

@rustbot rustbot added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Sep 30, 2021
ehuss pushed a commit to ehuss/rust that referenced this pull request Oct 4, 2021
Disable the evaluation cache when in intercrate mode

It's possible to use the same `InferCtxt` with both
an intercrate and non-intercrate `SelectionContext`. However,
the local (inferctxt) evaluation cache is not aware of this
distinction, so this kind of `InferCtxt` re-use will pollute
the cache wth bad results.

This commit avoids the issue by disabling the evaluation cache
entirely during intercrate mode.
ehuss pushed a commit to ehuss/rust that referenced this pull request Oct 4, 2021
…jackh726

Don't use projection cache or candidate cache in intercrate mode

Fixes rust-lang#88969

It appears that *just* disabling the evaluation cache (in rust-lang#88994)
leads to other issues involving intercrate mode caching. I suspect
that since we now always end up performing the full evaluation
in intercrate mode, we end up 'polluting' the candidate and projection
caches with results that depend on being in intercrate mode in some way.
Previously, we might have hit a cached evaluation (stored during
non-intercrate mode), and skipped doing this extra work in
intercrate mode.

The whole situation with intercrate mode caching is turning into
a mess. Ideally, we would remove intercrate mode entirely - however,
this might require waiting on Chalk.
@ehuss ehuss mentioned this pull request Oct 4, 2021
@ehuss ehuss removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Oct 4, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 4, 2021
[beta] Beta rollup

* Fix WinUWP std compilation errors due to I/O safety rust-lang#88587
* Disable RemoveZsts in generators to avoid query cycles rust-lang#88979
* Disable the evaluation cache when in intercrate mode rust-lang#88994
* Fix linting when trailing macro expands to a trailing semi rust-lang#88996
* Don't use projection cache or candidate cache in intercrate mode rust-lang#89125
* 2229: Mark insignificant dtor in stdlib rust-lang#89144
* Temporarily rename int_roundings functions to avoid conflicts rust-lang#89184
* [rfc 2229] Drop fully captured upvars in the same order as the regular drop code rust-lang#89208
* Use the correct edition for syntax highlighting doctests rust-lang#89277
* Don't normalize opaque types with escaping late-bound regions rust-lang#89285
* Update Let's Encrypt ROOT CA certificate in dist-(i686|x86_64)-linux docker images rust-lang#89486

Cargo update:
* - [beta] 1.56 backports (rust-lang/cargo#9958)
* - [beta] Revert "When a dependency does not have a version, git or path… (rust-lang/cargo#9912)
* - [beta] Fix rustc --profile=dev unstable check. (rust-lang/cargo#9901)
@Mark-Simulacrum Mark-Simulacrum modified the milestones: 1.57.0, 1.56.0 Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. 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.