Skip to content

Commit 8952854

Browse files
committed
Auto merge of #154122 - Zalathar:no-anon, r=nnethercote
Remove the `anon` query modifier Prior experiments: - rust-lang/rust#152268 - rust-lang/rust#153996 [Zulip thread: *Removing the `anon` query modifier*](https://rust-lang.zulipchat.com/#narrow/channel/582699-t-compiler.2Fquery-system/topic/Removing.20the.20.60anon.60.20query.20modifier/with/580760962) --- There are currently three queries that use the `anon` modifier: - `check_representability` - `check_representability_adt_ty` - `erase_and_anonymize_regions_ty` It seems that none of them are using `anon` in an essential way. According to comments and tests, the *representability* queries mainly care about not being eligible for forcing (despite having a recoverable key type), so that if a cycle does occur then the entire cycle will be on the query stack. Replacing `anon` with a new `no_force` modifier gives a modest perf improvement. The `erase_and_anonymize_regions_ty` query appears to be using `anon` to reduce the dep-graph overhead of a query that is expected to not call any other queries (and thus have no dependencies). Replacing `anon` with either `no_hash` or nothing appears to give only a very small perf hit on `cargo` benchmarks, which is justified by the fact that it lets us remove a lot of machinery for anonymous queries. We still need to retain some of the machinery for anonymous *tasks*, because the non-query task `DepKind::TraitSelect` still uses it. --- I have some ideas for a follow-up that will reduce dep-graph overhead by replacing *all* zero-dependency nodes with a singleton node, but I want to keep that separate in case it causes unexpected issues and needs to be bisected or reverted.
2 parents 5d0a0f3 + 751a323 commit 8952854

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

src/queries/incremental-compilation-in-detail.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,13 @@ deal with all of the above but so far that seemed like more trouble than it woul
418418

419419
## Query modifiers
420420

421+
> FIXME: Make [`rustc_middle::query::modifiers`] the home for query modifier documentation,
422+
> and migrate all other useful modifier docs there after verifying that they are still accurate.
423+
424+
[`rustc_middle::query::modifiers`]:
425+
https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/query/modifiers/index.html
426+
427+
421428
The query system allows for applying [modifiers][mod] to queries.
422429
These modifiers affect certain aspects of how the system treats the query with
423430
respect to incremental compilation:
@@ -437,6 +444,9 @@ respect to incremental compilation:
437444
as an optimization because the system can skip recording dependencies in
438445
the first place.
439446

447+
- `no_force` - Never "force" the dep nodes for this query, even if the query's
448+
key type is recoverable.
449+
440450
- `no_hash` - Applying `no_hash` to a query tells the system to not compute
441451
the fingerprint of the query's result.
442452
This has two consequences:
@@ -475,13 +485,6 @@ respect to incremental compilation:
475485
For example, it makes no sense to store values from upstream
476486
crates in the cache because they are already available in the upstream crate's metadata.
477487

478-
- `anon` - This attribute makes the system use "anonymous" dep-nodes for the given query.
479-
An anonymous dep-node is not identified by the corresponding query key.
480-
Instead, its ID is computed from the IDs of its dependencies.
481-
This allows the red-green system to do its change detection even if there is no
482-
query key available for a given dep-node -- something which is needed for
483-
handling trait selection because it is not based on queries.
484-
485488
[mod]: ../query.html#adding-a-new-kind-of-query
486489

487490

0 commit comments

Comments
 (0)