perf: Cache already-checked types in the privacy visitor - #160317
Draft
xmakro wants to merge 1 commit into
Draft
Conversation
Contributor
|
Something similar was tried in #147486, but the caching overhead was found to be too large in most cases. |
Contributor
|
@bors try @rust-timer queue |
Collaborator
|
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
This comment has been minimized.
This comment has been minimized.
Contributor
Needs a rebase first. |
Collaborator
|
This pull request is already queued and waiting for a try build to finish. |
xmakro
force-pushed
the
perf/privacy-accessible-type-cache
branch
from
August 1, 2026 17:25
0929cce to
6511e1d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The privacy checker walks the full type of every expression and pattern in a module, re-walking the same type once per node it appears on. This caches the types and generic-args that walked clean (no privacy error) and skips them next time. A walk's result depends only on the interned value and the fixed module being checked, so a value that walks clean once walks clean everywhere.
Only clean walks are cached, so nothing is lost: a type that errors is never cached and still fires at every span, and no dep-graph edges are dropped since the full walk already ran once in the same query.