Assert redundant incremental check#156599
Conversation
|
r? @chenyukang rustbot has assigned @chenyukang. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
I think we can clarify this change with a comment or by outright inlining that function. Not sure what to pick tho. |
|
Also that check is covered by tests, so I making it unconditionally panic would trigger following incremental tests failures:
|
|
I think we could change it to debug_assert and check if perf is affected. |
|
@rustbot reroll |
Making the existing helper function assert seems like a hazard if any other code starts calling it, so I think it's clearer to inline and remove the function. After inlining I think we can also get rid of the |
7a4bd2e to
ef2fa8a
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
What if we restart an incremental compilation with a working dep-graph, but the on-disk cache has been deleted? |
I think that shouldn't matter: rust/compiler/rustc_incremental/src/persist/save.rs Lines 61 to 63 in 783eb8c |
|
Indeed, here is where the rust/compiler/rustc_incremental/src/persist/load.rs Lines 122 to 147 in 783eb8c As long as we're in incremental mode, we fall back to creating an empty disk-cache struct if nothing could be loaded. So the field is only None in non-incremental mode. |
|
Should be good now I think. |
|
Oh wait, I think I misunderstood the concern. If the disk-cache was deleted since the last session, the OnDiskCache will be present but empty ... so even values that should be in the disk-cache will be absent, violating the assertion. So removing the check might be wrong after all. |
Right, I forgot about that. So can we make it a None for that case, just like I've assumed it in the beginning? |
2667e56 to
c23ce2e
Compare
|
Like that it should be ok, right? |
|
☔ The latest upstream changes (presumably #157149) made this pull request unmergeable. Please resolve the merge conflicts. |
So to incrementally execute
tcx.ensure_done().query()we first do query graph coloring to determine if nothing has changed and maybe color our query green. In that case forensure_okwe skip further execution and return. However forensure_donewe do this check:rust/compiler/rustc_query_impl/src/execution.rs
Lines 601 to 608 in 7c3c88f
Which in turn looks up a serialized query value:
rust/compiler/rustc_middle/src/query/on_disk_cache.rs
Lines 338 to 343 in 7c3c88f
However, we only serialize query values if the pure (I've checked) function
will_cache_on_disk_for_key_fnfrom above returns true:rust/compiler/rustc_query_impl/src/plumbing.rs
Lines 95 to 99 in 7c3c88f
As such
loadable_from_diskshould be able to simply check iftcx.query_system.on_disk_cacheis loaded and assume query value is present, assuming thatwill_cache_on_disk_for_key_fnreturned true.