summary refs log tree commit diff
path: root/compiler/rustc_query_impl
AgeCommit message (Collapse)AuthorLines
2022-05-08Move lint expectation checking into a separate query (RFC 2383)xFrednet-0/+10
2022-05-04Enable tracing for all queryiesOli Scherer-0/+4
2022-04-21implement (as of now still unused) query for valtree -> constvalue conversionb-naber-0/+11
2022-04-17Stop using CRATE_DEF_INDEX.Camille GILLOT-2/+2
`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.
2022-03-30rework implementation for inherent impls for builtin typeslcnr-0/+20
2022-03-28Propagate `parallel_compiler` feature through rustc crates. Turned off ↵klensy-1/+4
feature gives change of builded crates: 238 -> 224.
2022-02-27Auto merge of #94084 - Mark-Simulacrum:drop-sharded, r=cjgillotbors-9/+8
Avoid query cache sharding code in single-threaded mode In non-parallel compilers, this is just adding needless overhead at compilation time (since there is only one shard statically anyway). This amounts to roughly ~10 seconds reduction in bootstrap time, with overall neutral (some wins, some losses) performance results. Parallel compiler performance should be largely unaffected by this PR; sharding is kept there.
2022-02-25Switch bootstrap cfgsMark Rousskov-1/+1
2022-02-21Auto merge of #94066 - Mark-Simulacrum:factor-out-simple-def-kind, r=davidtwcobors-26/+4
Remove SimpleDefKind Now that rustc_query_system depends on rustc_hir, we can just directly make use of the regular DefKind.
2022-02-20Delete QueryLookupMark Rousskov-2/+1
This was largely just caching the shard value at this point, which is not particularly useful -- in the use sites the key was being hashed nearby anyway.
2022-02-20Move Sharded maps into each QueryCache implMark Rousskov-7/+7
2022-02-17Remove SimpleDefKindMark Rousskov-26/+4
2022-02-16Move ty::print methods to Drop-based scope guardsMark Rousskov-4/+5
2022-02-15Overhaul `Const`.Nicholas Nethercote-2/+2
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as this: ``` pub struct Const<'tcx>(&'tcx Interned<ConstS>); ``` This now matches `Ty` and `Predicate` more closely, including using pointer-based `eq` and `hash`. Notable changes: - `mk_const` now takes a `ConstS`. - `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a we need separate arena for it, because we can't use the `Dropless` one any more. - Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes - Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes. - Lots of tedious sigil fiddling.
2022-02-15Overhaul `TyS` and `Ty`.Nicholas Nethercote-2/+2
Specifically, change `Ty` from this: ``` pub type Ty<'tcx> = &'tcx TyS<'tcx>; ``` to this ``` pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>); ``` There are two benefits to this. - It's now a first class type, so we can define methods on it. This means we can move a lot of methods away from `TyS`, leaving `TyS` as a barely-used type, which is appropriate given that it's not meant to be used directly. - The uniqueness requirement is now explicit, via the `Interned` type. E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather than via `TyS`, which wasn't obvious at all. Much of this commit is boring churn. The interesting changes are in these files: - compiler/rustc_middle/src/arena.rs - compiler/rustc_middle/src/mir/visit.rs - compiler/rustc_middle/src/ty/context.rs - compiler/rustc_middle/src/ty/mod.rs Specifically: - Most mentions of `TyS` are removed. It's very much a dumb struct now; `Ty` has all the smarts. - `TyS` now has `crate` visibility instead of `pub`. - `TyS::make_for_test` is removed in favour of the static `BOOL_TY`, which just works better with the new structure. - The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned` (pointer-based, for the `Equal` case) and partly on `TyS` (contents-based, for the other cases). - There are many tedious sigil adjustments, i.e. adding or removing `*` or `&`. They seem to be unavoidable.
2022-02-09Auto merge of #93741 - Mark-Simulacrum:global-job-id, r=cjgillotbors-12/+22
Refactor query system to maintain a global job id counter This replaces the per-shard counters with a single global counter, simplifying the JobId struct down to just a u64 and removing the need to pipe a DepKind generic through a bunch of code. The performance implications on non-parallel compilers are likely minimal (this switches to `Cell<u64>` as the backing storage over a `u64`, but the latter was already inside a `RefCell` so it's not really a significance divergence). On parallel compilers, the cost of a single global u64 counter may be more significant: it adds a serialization point in theory. On the other hand, we can imagine changing the counter to have a thread-local component if it becomes worrisome or some similar structure. The new design is sufficiently simpler that it warrants the potential for slight changes down the line if/when we get parallel compilation to be more of a default. A u64 counter, instead of u32 (the old per-shard width), is chosen to avoid possibly overflowing it and causing problems; it is effectively impossible that we would overflow a u64 counter in this context.
2022-02-09Auto merge of #93724 - Mark-Simulacrum:drop-query-stats, r=michaelwoeristerbors-115/+0
Delete -Zquery-stats infrastructure These statistics are computable from the self-profile data and/or ad-hoc collectable as needed, and in the meantime contribute to rustc bootstrap times -- locally, this PR shaves ~2.5% from rustc_query_impl builds in instruction counts. If this does lose some functionality we want to keep, I think we should migrate it to self-profile (or a similar interface) rather than this ad-hoc reporting.
2022-02-08Switch QueryJobId to a single global counterMark Rousskov-12/+22
This replaces the per-shard counters with a single global counter, simplifying the JobId struct down to just a u64 and removing the need to pipe a DepKind generic through a bunch of code. The performance implications on non-parallel compilers are likely minimal (this switches to `Cell<u64>` as the backing storage over a `u64`, but the latter was already inside a `RefCell` so it's not really a significance divergence). On parallel compilers, the cost of a single global u64 counter may be more significant: it adds a serialization point in theory. On the other hand, we can imagine changing the counter to have a thread-local component if it becomes worrisome or some similar structure. The new design is sufficiently simpler that it warrants the potential for slight changes down the line if/when we get parallel compilation to be more of a default. A u64 counter, instead of u32 (the old per-shard width), is chosen to avoid possibly overflowing it and causing problems; it is effectively impossible that we would overflow a u64 counter in this context.
2022-02-0814956 -> 14952 exportsklensy-2/+2
2022-02-0715221 -> 14956 exportsklensy-1/+1
2022-02-06Delete query statsMark Rousskov-115/+0
These statistics are computable from the self-profile data and/or ad-hoc collectable as needed, and in the meantime contribute to rustc bootstrap times.
2022-02-01add a rustc::query_stability lintlcnr-0/+1
2022-01-22Make `Decodable` and `Decoder` infallible.Nicholas Nethercote-64/+53
`Decoder` has two impls: - opaque: this impl is already partly infallible, i.e. in some places it currently panics on failure (e.g. if the input is too short, or on a bad `Result` discriminant), and in some places it returns an error (e.g. on a bad `Option` discriminant). The number of places where either happens is surprisingly small, just because the binary representation has very little redundancy and a lot of input reading can occur even on malformed data. - json: this impl is fully fallible, but it's only used (a) for the `.rlink` file production, and there's a `FIXME` comment suggesting it should change to a binary format, and (b) in a few tests in non-fundamental ways. Indeed #85993 is open to remove it entirely. And the top-level places in the compiler that call into decoding just abort on error anyway. So the fallibility is providing little value, and getting rid of it leads to some non-trivial performance improvements. Much of this commit is pretty boring and mechanical. Some notes about a few interesting parts: - The commit removes `Decoder::{Error,error}`. - `InternIteratorElement::intern_with`: the impl for `T` now has the same optimization for small counts that the impl for `Result<T, E>` has, because it's now much hotter. - Decodable impls for SmallVec, LinkedList, VecDeque now all use `collect`, which is nice; the one for `Vec` uses unsafe code, because that gave better perf on some benchmarks.
2022-01-19Show a more informative panic message when `DefPathHash` does not existAaron Hill-1/+3
This should hopefully make it easier to debug incremental compilation bugs like #93096 without affecting performance.
2022-01-10Update rayon and rustc-rayonJosh Stone-1/+1
2021-12-23Import `SourceFile`s from crate before decoding foreign `Span`Aaron Hill-0/+14
Fixes #92163 Fixes #92014 When writing to the incremental cache, we encode all `Span`s we encounter, regardless of whether or not their `SourceFile` comes from the local crate, or from a foreign crate. When we decode a `Span`, we use the `StableSourceFileId` we encoded to locate the matching `SourceFile` in the current session. If this id corresponds to a `SourceFile` from another crate, then we need to have already imported that `SourceFile` into our current session. This usually happens automatically during resolution / macro expansion, when we try to resolve definitions from other crates. In certain cases, however, we may try to load a `Span` from a transitive dependency without having ever imported the `SourceFile`s from that crate, leading to an ICE. This PR fixes the issue by calling `imported_source_files()` when we encounter a `SourceFile` with a foreign `CrateNum`. This ensures that all `SourceFile`s from that crate are imported into the current session.
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-2/+2
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-2/+2
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-14Remove `in_band_lifetimes` from `rustc_query_impl`LegionMammal978-8/+7
See #91867 for more information.
2021-12-12Query modifierDeadbeef-0/+12
2021-12-09Remove redundant [..]sest31-1/+1
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-1/+0
2021-10-25Avoid a branch on key being local for queries that use the same local and ↵bjorn3-8/+20
extern providers
2021-10-25Auto merge of #90210 - cjgillot:qarray2, r=Mark-Simulacrumbors-40/+32
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-3/+2
2021-10-23Build the query vtable directly.Camille GILLOT-38/+31
2021-10-21Do not depend on the stored value when trying to cache on disk.Camille GILLOT-2/+2
2021-10-20Build jump table at runtime.Camille GILLOT-59/+71
2021-10-20Invoke callbacks from rustc_middle.Camille GILLOT-35/+2
2021-10-20Merge two query callbacks arrays.Camille GILLOT-67/+34
2021-10-20Make hash_result an Option.Camille GILLOT-12/+6
2021-10-20Move def_path_hash_to_def_id to rustc_middle.Camille GILLOT-18/+1
2021-10-20Rollup merge of #87404 - rylev:artifact-size-profiling, r=wesleywiserYuki Okushi-1/+1
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-15allow `potential_query_instability` everywherelcnr-0/+1
2021-10-11Remove built-in cache_hit trackingMark Rousskov-27/+0
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-09Auto merge of #89343 - Mark-Simulacrum:no-args-queries, r=cjgillotbors-3/+4
Refactor fingerprint reconstruction This PR replaces can_reconstruct_query_key with fingerprint_style, which returns the style of the fingerprint for that query. This allows us to avoid trying to extract a DefId (or equivalent) from keys which *are* reconstructible because they're () but not as DefIds. This is done with the goal of fixing -Zdump-dep-graph, which seems to have broken a while ago (I didn't try to bisect). Currently even on a `fn main() {}` file it'll ICE (you need to also pass -Zquery-dep-graph for it to work at all), and this patch indirectly fixes the cause of that ICE. This also adds a test for it continuing to work.
2021-10-08Auto merge of #89619 - michaelwoerister:incr-vtables, r=nagisabors-0/+11
Turn vtable_allocation() into a query This PR removes the untracked vtable-const-allocation cache from the `tcx` and turns the `vtable_allocation()` method into a query. The change is pretty straightforward and should be backportable without too much effort. Fixes https://github.com/rust-lang/rust/issues/89598.
2021-10-07Turn tcx.vtable_allocation() into a query.Michael Woerister-0/+11
2021-10-07Update to measureme v10Ryan Levick-1/+1