-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Replace most of rustc_metadata::schema with something based on queries. #65407
Copy link
Copy link
Open
Labels
A-metadataArea: Crate metadataArea: Crate metadataC-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.I-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-metadataArea: Crate metadataArea: Crate metadataC-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.I-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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 theTvalue.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
schemawhich 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/decoderboilerplate for everythingpredicatesinEntryvssuper_predicatesinTraitDataLazypointersEntry's 15 fields are all decoded to read only 1, most of the timeIn #59953, the table of
Entrys is replaced by a table for everything that used to be in anEntryfield.For example, the
predicates_ofquery 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 sprawlingenumwith even two levels ofLazyindirection 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_metadataand 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 thanEntryKindtoday.