about summary refs log tree commit diff
path: root/compiler/rustc_query_system
AgeCommit message (Collapse)AuthorLines
2022-01-05Adjust assert_default_hashing_controlsAaron Hill-0/+7
2022-01-05Ensure that `Fingerprint` caching respects hashing configurationAaron Hill-23/+28
Fixes #92266 In some `HashStable` impls, we use a cache to avoid re-computing the same `Fingerprint` from the same structure (e.g. an `AdtDef`). However, the `StableHashingContext` used can be configured to perform hashing in different ways (e.g. skipping `Span`s). This configuration information is not included in the cache key, which will cause an incorrect `Fingerprint` to be used if we hash the same structure with different `StableHashingContext` settings. To fix this, the configuration settings of `StableHashingContext` are split out into a separate `HashingControls` struct. This struct is used as part of the cache key, ensuring that our caches always produce the correct result for the given settings. With this in place, we now turn off `Span` hashing during the entire process of computing the hash included in legacy symbols. This current has no effect, but will matter when a future PR starts hashing more `Span`s that we currently skip.
2022-01-04Auto merge of #92259 - Aaron1011:normal-mod-hashing, r=michaelwoeristerbors-24/+1
Remove special-cased stable hashing for HIR module All other 'containers' (e.g. `impl` blocks) hashed their contents in the normal, order-dependent way. However, `Mod` was hashing its contents in a (sort-of) order-independent way. However, the exact order is exposed to consumers through `Mod.item_ids`, and through query results like `hir_module_items`. Therefore, stable hashing needs to take the order of items into account, to avoid fingerprint ICEs. Unforuntately, I was unable to directly build a reproducer for the ICE, due to the behavior of `Fingerprint::combine_commutative`. This operation swaps the upper and lower `u64` when constructing the result, which makes the function non-associative. Since we start the hashing of module items by combining `Fingerprint::ZERO` with the first item, it's difficult to actually build an example where changing the order of module items leaves the final hash unchanged. However, this appears to have been hit in practice in #92218 While we're not able to reproduce it, the fact that proc-macros are involved (which can give an entire module the same span, preventing any span-related invalidations) makes me confident that the root cause of that issue is our method of hashing module items. This PR removes all of the special handling for `Mod`, instead deriving a `HashStable` implementation. This makes `Mod` consistent with other 'contains' like `Impl`, which hash their contents through the typical derive of `HashStable`.
2021-12-24Remove special-cased stable hashing for HIR moduleAaron Hill-24/+1
All other 'containers' (e.g. `impl` blocks) hashed their contents in the normal, order-dependent way. However, `Mod` was hashing its contents in a (sort-of) order-independent way. However, the exact order is exposed to consumers through `Mod.item_ids`, and through query results like `hir_module_items`. Therefore, stable hashing needs to take the order of items into account, to avoid fingerprint ICEs. Unforuntately, I was unable to directly build a reproducer for the ICE, due to the behavior of `Fingerprint::combine_commutative`. This operation swaps the upper and lower `u64` when constructing the result, which makes the function non-associative. Since we start the hashing of module items by combining `Fingerprint::ZERO` with the first item, it's difficult to actually build an example where changing the order of module items leaves the final hash unchanged. However, this appears to have been hit in practice in #92218 While we're not able to reproduce it, the fact that proc-macros are involved (which can give an entire module the same span, preventing any span-related invalidations) makes me confident that the root cause of that issue is our method of hashing module items. This PR removes all of the special handling for `Mod`, instead deriving a `HashStable` implementation. This makes `Mod` consistent with other 'contains' like `Impl`, which hash their contents through the typical derive of `HashStable`.
2021-12-23Adjust wording of commentAaron Hill-8/+13
2021-12-23Address review commentsAaron Hill-9/+64
2021-12-23Some cleanupAaron Hill-5/+4
2021-12-23Ban deps only during query loading from diskAaron Hill-3/+9
2021-12-23Error if we try to read dep during deserializationAaron Hill-3/+12
2021-12-21Add `#[rustc_clean(loaded_from_disk)]` to assert loading of query resultAaron Hill-0/+18
Currently, you can use `#[rustc_clean]` to assert to that a particular query (technically, a `DepNode`) is green or red. However, a green `DepNode` does not mean that the query result was actually deserialized from disk - we might have never re-run a query that needed the result. Some incremental tests are written as regression tests for ICEs that occured during query result decoding. Using `#[rustc_clean(loaded_from_disk="typeck")]`, you can now assert that the result of a particular query (e.g. `typeck`) was actually loaded from disk, in addition to being green.
2021-12-14Stabilize iter::zip.PFPoitras-1/+0
2021-11-29std: Stabilize the `thread_local_const_init` featureAlex Crichton-1/+0
This commit is intended to follow the stabilization disposition of the FCP that has now finished in #84223. This stabilizes the ability to flag thread local initializers as `const` expressions which enables the macro to generate more efficient code for accessing it, notably removing runtime checks for initialization. More information can also be found in #84223 as well as the tests where the feature usage was removed in this PR. Closes #84223
2021-11-22Manually outline error on incremental_verify_ichMark Rousskov-24/+74
This reduces codegen for rustc_query_impl by 169k lines of LLVM IR, representing a 1.2% improvement.
2021-11-08Auto merge of #90361 - Mark-Simulacrum:always-verify, r=michaelwoeristerbors-1/+14
Enable verification for 1/32th of queries loaded from disk This is a limited enabling of incremental verification for query results loaded from disk, which previously did not run without -Zincremental-verify-ich. If enabled for all queries, we see a probably unacceptable hit of ~50% in the worst case, so this pairs back the verification to a more limited set based on the hash key. Per collected [perf results](https://github.com/rust-lang/rust/pull/84227#issuecomment-953350582), this is a regression of at most 7% on coercions opt incr-unchanged, and typically less than 0.5% on other benchmarks (largely limited to incr-unchanged). I believe this is acceptable performance to land, and we can either ratchet it up or down fairly easily. We have no real sense of whether this will lead to a large amount of assertions in the wild, but since those assertions may lead to miscompilations today, it seems potentially warranted. We have a good bit of lead time until the next stable release, though the holiday season will also start soon; we may wish to discuss the timing of enabling this and weigh the desire to prevent (possible) miscompilations against assertions. cc `@rust-lang/wg-incr-comp`
2021-10-29Auto merge of #90380 - Mark-Simulacrum:revert-89558-query-stable-lint, r=lcnrbors-1/+0
Revert "Add rustc lint, warning when iterating over hashmaps" Fixes perf regressions introduced in https://github.com/rust-lang/rust/pull/90235 by temporarily reverting the relevant PR.
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-1/+0
2021-10-28Enable verification for 1/32th of queries loaded from diskMark Rousskov-1/+14
2021-10-28Auto merge of #90145 - cjgillot:sorted-map, r=michaelwoeristerbors-4/+4
Use SortedMap in HIR. Closes https://github.com/rust-lang/rust/issues/89788 r? `@ghost`
2021-10-25Auto merge of #90210 - cjgillot:qarray2, r=Mark-Simulacrumbors-58/+18
Build the query vtable directly. Continuation of https://github.com/rust-lang/rust/pull/89978. This shrinks the query interface and attempts to reduce the amount of function pointer calls.
2021-10-24Rollup merge of #89558 - lcnr:query-stable-lint, r=estebankMatthias Krüger-0/+1
Add rustc lint, warning when iterating over hashmaps r? rust-lang/wg-incr-comp
2021-10-23Do not require QueryCtxt for cache_on_disk.Camille GILLOT-1/+1
2021-10-23Build the query vtable directly.Camille GILLOT-58/+18
2021-10-21Use SortedMap in HIR.Camille GILLOT-4/+4
2021-10-21Do not depend on the stored value when trying to cache on disk.Camille GILLOT-5/+5
2021-10-20Address review.Camille GILLOT-1/+1
2021-10-20Inline DepNodeParams methods.Camille GILLOT-1/+4
2021-10-20Compute query vtable manually.Camille GILLOT-27/+29
2021-10-20Store node_intern_event_id in CurrentDepGraph.Camille GILLOT-22/+24
2021-10-20Build jump table at runtime.Camille GILLOT-59/+20
2021-10-20Invoke callbacks from rustc_middle.Camille GILLOT-11/+10
2021-10-20Merge two query callbacks arrays.Camille GILLOT-22/+25
2021-10-20Drop has_params.Camille GILLOT-5/+2
2021-10-20Make hash_result an Option.Camille GILLOT-25/+18
2021-10-20Rollup merge of #87404 - rylev:artifact-size-profiling, r=wesleywiserYuki Okushi-3/+7
Add support for artifact size profiling This adds support for profiling artifact file sizes (incremental compilation artifacts and query cache to begin with). Eventually we want to track this in perf.rlo so we can ensure that file sizes do not change dramatically on each pull request. This relies on support in measureme: https://github.com/rust-lang/measureme/pull/169. Once that lands we can update this PR to not point to a git dependency. This was worked on together with `@michaelwoerister.` r? `@wesleywiser`
2021-10-19Auto merge of #89933 - est31:let_else, r=michaelwoeristerbors-7/+4
Adopt let_else across the compiler This performs a substitution of code following the pattern: ``` let <id> = if let <pat> = ... { identity } else { ... : ! }; ``` To simplify it to: ``` let <pat> = ... { identity } else { ... : ! }; ``` By adopting the `let_else` feature (cc #87335). The PR also updates the syn crate because the currently used version of the crate doesn't support `let_else` syntax yet. Note: Generally I'm the person who *removes* usages of unstable features from the compiler, not adds more usages of them, but in this instance I think it hopefully helps the feature get stabilized sooner and in a better state. I have written a [comment](https://github.com/rust-lang/rust/issues/87335#issuecomment-944846205) on the tracking issue about my experience and what I feel could be improved before stabilization of `let_else`.
2021-10-18Auto merge of #89124 - cjgillot:owner-info, r=michaelwoeristerbors-56/+54
Index and hash HIR as part of lowering Part of https://github.com/rust-lang/rust/pull/88186 ~Based on https://github.com/rust-lang/rust/pull/88880 (see merge commit).~ Once HIR is lowered, it is later indexed by the `index_hir` query and hashed for `crate_hash`. This PR moves those post-processing steps to lowering itself. As a side objective, the HIR crate data structure is refactored as an `IndexVec<LocalDefId, Option<OwnerInfo<'hir>>>` where `OwnerInfo` stores all the relevant information for an HIR owner. r? `@michaelwoerister` cc `@petrochenkov`
2021-10-16Adopt let_else across the compilerest31-7/+4
This performs a substitution of code following the pattern: let <id> = if let <pat> = ... { identity } else { ... : ! }; To simplify it to: let <pat> = ... { identity } else { ... : ! }; By adopting the let_else feature.
2021-10-15allow `potential_query_instability` everywherelcnr-0/+1
2021-10-11Remove built-in cache_hit trackingMark Rousskov-22/+1
This was already only enabled in debug_assertions builds. Generally, it seems like most use cases that would use this could also use the -Zself-profile flag which also tracks cache hits (in all builds), and so the extra cfg's and such are not really necessary. This is largely just a small cleanup though, which primarily is intended to make other changes easier by avoiding the need to deal with this field.
2021-10-10Compute full HIR hash during lowering.Camille GILLOT-26/+10
2021-10-09Forbid hashing HIR outside of indexing.Camille GILLOT-30/+44
2021-10-07Add support for artifact size profilingRyan Levick-3/+7
2021-10-06Query the fingerprint style during key reconstructionMark Rousskov-9/+30
Keys can be reconstructed from fingerprints that are not DefPathHash, but then we cannot extract a DefId from them.
2021-10-03Add some inlining.Camille GILLOT-0/+8
2021-10-03Access StableHashingContext in rustc_query_system.Camille GILLOT-22/+16
2021-10-03Move ICH to rustc_query_system.Camille GILLOT-1/+531
2021-09-20Migrate to 2021Mark Rousskov-1/+1
2021-09-18Auto merge of #82183 - michaelwoerister:lazier-defpathhash-loading2, ↵bors-28/+0
r=wesleywiser Simplify lazy DefPathHash decoding by using an on-disk hash table. This PR simplifies the logic around mapping `DefPathHash` values encountered during incremental compilation to valid `DefId`s in the current session. It is able to do so by using an on-disk hash table encoding that allows for looking up values directly, i.e. without deserializing the entire table. The main simplification comes from not having to keep track of `DefPathHashes` being used during the compilation session.
2021-09-15Use explicit log level in tracing instrument macroTomasz Miąsko-2/+2
Specify a log level in tracing instrument macro explicitly. Additionally reduce the used log level from a default info level to a debug level (all of those appear to be developer oriented logs, so there should be no need to include them in release builds).
2021-09-14Remove RawDefId tracking infrastructure from incr. comp. framework.Michael Woerister-28/+0
This infrastructure is obsolete now with the new encoding scheme for the DefPathHash->DefIndex maps in crate metadata.