Replace most of rustc_metadata::schema with something based on queries. #65407
Labels
A-metadata
Area: Crate metadata
C-cleanup
Category: PRs that clean code up or issues documenting cleanup.
I-compiletime
Issue: Problems and improvements with respect to compile times.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Right now (cross-crate) "metadata" is encoded as an ad-hoc heterogeneous tree, described in
rustc_metadata::schema
, withLazy<T>
acting as indirection (as in "pointer toT
", inside the "metadata" blob) and letting the user choose whether to decode of theT
value.There is also a random-access array (called "table" in #59953), which is currently only used for
Entry
.This cross-crate system predates the on-demand/incremental query system, and we have accumulated a lot of data in the
schema
which is similar (but not always identical) to certain queries, and additional code to present that information through queries.The disadvantages I see with the current approach are:
schema
/encoder
/decoder
boilerplate for everythingpredicates
inEntry
vssuper_predicates
inTraitData
Lazy
pointersEntry
's 15 fields are all decoded to read only 1, most of the timeIn #59953, the table of
Entry
s is replaced by a table for everything that used to be in anEntry
field.For example, the
predicates_of
query would then performpredicates[i].decode()
instead ofentries[i].decode().predicates.decode()
(irrelevant details elided).This is effectively a trade-off:
However, we can go further - #59953 doesn't touch
EntryKind
, which is still a sprawlingenum
with even two levels ofLazy
indirection in places.Ultimately, we could have "cross-crate metadata" be one table per query in most cases. This would accentuate the trade-off from #59953 further, but it would also allow simplifying
rustc_metadata
and unifying it further with incremental save&restore.One of the queries that would benefit most from this is
def_kind
, which could be stored as a fully-populated table of bytes, much more compact and cheaper to decode thanEntryKind
today.The text was updated successfully, but these errors were encountered: