-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Make AST->HIR lowering incremental #88186
Conversation
Some changes occurred in src/tools/clippy. cc @rust-lang/clippy |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit aa6204b46dcb5a45bc915430bfe05975d4ae38ea with merge f5e4230e3edf7c9689e3a4b9fde9426a3f7630ff... |
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
Queued f5e4230e3edf7c9689e3a4b9fde9426a3f7630ff with parent 59ce765, future comparison URL. |
Finished benchmarking try commit (f5e4230e3edf7c9689e3a4b9fde9426a3f7630ff): comparison url. Summary: This change led to very large relevant mixed results 🤷 in compiler performance.
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. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @bors rollup=never |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
fa7f4c1
to
ad89395
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This PR features a sizeable perf regression, up to 11%. I believe this is entirely due to query overhead: this PR requires one extra query invocation for each |
☔ The latest upstream changes (presumably #95662) made this pull request unmergeable. Please resolve the merge conflicts. |
I'm setting this PR to blocked for now. #95573 looks promising! |
☔ The latest upstream changes (presumably #91557) made this pull request unmergeable. Please resolve the merge conflicts. |
This is global query, so it will probably be invalidated anyway. This was creating a compound dependency from any typeck to any hir_owner: typeck -> incoherent_impls -> crate_incoherent_impls -> crate_inherent_impls -> hir_owner. This dependency was (incorrectly?) flagged by the ui/dep-graph tests as problematic.
☔ The latest upstream changes (presumably #93803) made this pull request unmergeable. Please resolve the merge conflicts. |
Make lowering a query Split from rust-lang#88186. This PR refactors the relationship between lowering and the resolver outputs in order to make lowering itself a query. In a first part, lowering is changed to avoid modifying resolver outputs, by maintaining its own data structures for creating new `NodeId`s and so. Then, the `TyCtxt` is modified to allow creating new `LocalDefId`s from inside it. This is done by: - enclosing `Definitions` in a lock, so as to allow modification; - creating a query `register_def` whose purpose is to declare a `LocalDefId` to the query system. See `TyCtxt::create_def` and `TyCtxt::iter_local_def_id` for more detailed explanations of the design.
Implementation of MCP rust-lang/compiler-team#452
AST->HIR lowering is currently done ahead of the construction of the incremental compilation engine. This issue proposes to make lowering incremental by introducing a query
lower_to_hir(def: LocalDefId) -> Option<&hir::OwnerInfo<'_>>
which lowers the AST item corresponding to definition def into the corresponding HIR and some associated information.The objective is to eventually skip lowering some parts of the AST, and to allow progress towards making resolution and expansion incremental.
The proposed design is as follows:
hir::Crate
, effectively makinghir::Crate
anIndexVec<LocalDefId, Option<OwnerInfo<'_>>>
;LocalDefId
, using anIndexVec<LocalDefId, AstOwner>
whereAstOwner
is an enum holdingOwningRef<Lrc<Crate>, ItemLike>
forItemLike
different AST item types;One of the most subtle changes is (*), which allows to create new definitions from inside queries. It is made safe using an eval-always query which forces re-execution of its caller, and effectively enforces the side-effects creating the definition. The first time definitions are iterated over (for instance for metadata output), a read-lock to the definitions is leaked, which seals the list of definitions.
This PR is blocked on:
The query scheme should basically look like this:
r? @michaelwoerister as requested on Zulip