|
| 1 | +--- |
| 2 | +title: 2019-12-06 end-to-end query PRs |
| 3 | +type: docs |
| 4 | +--- |
| 5 | + |
| 6 | +# Design Meeting 2019-12-06 -- librustc_interface queries |
| 7 | + |
| 8 | +## Links |
| 9 | + |
| 10 | +* [Zulip topic of the discussion](https://zulip-archive.rust-lang.org/131828tcompiler/75795designmeeting20191206.html) |
| 11 | +* [Compiler team issue](https://github.com/rust-lang/compiler-team/issues/175) |
| 12 | +* [Pre-design meeting Zulip topic](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/pre-design.20meeting.202019-12-05) |
| 13 | +* [Internals thread](https://internals.rust-lang.org/t/migrating-rustc-interface-queries-to-proper-librustc-queries/10433) with descriptions of PRs |
| 14 | + |
| 15 | +## Background |
| 16 | + |
| 17 | +* Goal is **end-to-end queries** |
| 18 | + * Benefits: Simpler overall model |
| 19 | + * Incremental extending back to parsing |
| 20 | + * mw has done measurements suggesting that on larger crates some 40% of the compilation time comes from |
| 21 | + * Parallel compilation would be more effective, if done on the basis of queries |
| 22 | +* Agenda |
| 23 | + * Tough to frame:) |
| 24 | + * Most important question to settle is what overall stategy we plan to take |
| 25 | + * Do we want to try and land / rebase these PRs? |
| 26 | + * Try a different tack? |
| 27 | + * Hold off and let other things progess? |
| 28 | + |
| 29 | +## Commentary on the meeting |
| 30 | + |
| 31 | +This is written after the fact, and is an attempt by nikomatsakis to capture some of the key considerations. |
| 32 | + |
| 33 | +* The PRs were written with the goal of moving rust immediately to an end-to-end query system |
| 34 | + * the queries that get created here are not, however, as clean as one might expect |
| 35 | + * as an example, instead of creating fine-grained queries for handling HIR, we would create a single HIR Map query and retain today's special case code that tries to track which bits of the data the methods on the HIR map access |
| 36 | +* An alternative approach would be to move more slowly but work more on the actual design of each piece |
| 37 | + * We might start with the HIR, decide on the actual representation that we want, and refactor into that |
| 38 | + * And then move backwards to name resolution |
| 39 | + * This overlaps somewhat with rust-analyzer, which has been built "from the ground up" with queries in mind, and thus has been figuring out some of what is needed here |
| 40 | +* For context, there are definitely benefits from changing the line around the "set of things captured in the query system" |
| 41 | + * e.g. big parts of the webrender-check compilation takes place before incremental even starts |
| 42 | +* The concerns with the PRs are that |
| 43 | + * we are kind of creating more tech debt before we start to pay it off |
| 44 | + * since the designs are not the designs that we ultimately want |
| 45 | + * there isn't really a precise enough consensus around the end state that we want |
| 46 | + * and thus trying to move incrementally means we are kind of ambling without a clear goal |
| 47 | + * and likely to wind up with something incoherent |
| 48 | + * the PRs introduce more special cases into the query system, not fewer |
| 49 | +* On the other hand |
| 50 | + * moving quickly to create queries might unlock other improvements, help us eliminate shared state |
| 51 | + * maybe you see this as an "obvious first step whatever we do", in which case there isn't a lot of room to block |
| 52 | + * counterargument is that these PRs are each quite complex and take a lot of reviewing load to manage etc |
| 53 | +* We discussed a fair amount what a desirable design for HIR might look like, [starting around here](https://zulip-archive.rust-lang.org/131828tcompiler/75795designmeeting20191206.html#182771577) |
| 54 | + * it seemed like there was general consensus around a "vague sketch" where you had `tcx.hir(def_id)` give you back some kind of `ItemData` that contained the data for a particular item |
| 55 | + * no 'special cases' needed in the query system |
| 56 | +* [Alternative proposal](https://zulip-archive.rust-lang.org/131828tcompiler/75795designmeeting20191206.html#182772402) |
| 57 | + * close the PRs |
| 58 | + * encourage creation of a WG to work out a design for HIR, HIR-ID and the like and bring that design forward |
| 59 | + * land new PRs working in that direction |
| 60 | + * this overlaps heavily with rust-analyzer and could even take place in that context |
| 61 | +* Towards the end, some topics were raised that were not fleshed out |
| 62 | + * such as whether a `DefId` could be a "interned" DefPath (or whether it already is) |
| 63 | + * the need for 'queries that depend on queries' and what that means |
0 commit comments