Skip to content

perf: Cache already-checked types in the privacy visitor - #160317

Draft
xmakro wants to merge 1 commit into
rust-lang:mainfrom
xmakro:perf/privacy-accessible-type-cache
Draft

perf: Cache already-checked types in the privacy visitor#160317
xmakro wants to merge 1 commit into
rust-lang:mainfrom
xmakro:perf/privacy-accessible-type-cache

Conversation

@xmakro

@xmakro xmakro commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

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.

@rustbot rustbot added 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. labels Aug 1, 2026
@petrochenkov petrochenkov self-assigned this Aug 1, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

Something similar was tried in #147486, but the caching overhead was found to be too large in most cases.

@petrochenkov

Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer

Copy link
Copy Markdown
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 1, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

Needs a rebase first.

@rust-timer

Copy link
Copy Markdown
Collaborator

This pull request is already queued and waiting for a try build to finish.

@petrochenkov petrochenkov removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 1, 2026
@xmakro
xmakro force-pushed the perf/privacy-accessible-type-cache branch from 0929cce to 6511e1d Compare August 1, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

4 participants