about summary refs log tree commit diff
path: root/compiler/rustc_query_impl/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2023-11-15Bump cfg(bootstrap)sMark Rousskov-2/+2
2023-10-08rustdoc: remove rust logo from non-Rust cratesMichael Howell-0/+2
2023-09-21Move `DepKind` to `rustc_query_system` and define it as `u16`John Kåre Alsaker-2/+4
2023-08-27Pass ErrorGuaranteed to cycle errorMichael Goulet-2/+3
2023-08-23Bump cfg(bootstrap)Mark Rousskov-1/+1
2023-08-03Add `internal_features` lintNilstrieb-0/+1
It lints against features that are inteded to be internal to the compiler and standard library. Implements MCP #596. We allow `internal_features` in the standard library and compiler as those use many features and this _is_ the standard library from the "internal to the compiler and standard library" after all. Marking some features as internal wasn't exactly the most scientific approach, I just marked some mostly obvious features. While there is a categorization in the macro, it's not very well upheld (should probably be fixed in another PR). We always pass `-Ainternal_features` in the testsuite About 400 UI tests and several other tests use internal features. Instead of throwing the attribute on each one, just always allow them. There's nothing wrong with testing internal features^^
2023-05-21Replace `QueryStruct` with arrays local to `rustc_query_impl`John Kåre Alsaker-3/+4
2023-05-18Merge query property modules into oneJohn Kåre Alsaker-3/+2
2023-05-17Finish move of query.rsJohn Kåre Alsaker-1/+1
2023-05-16Auto merge of #108062 - Zoxc:spec-incr, r=cjgillotbors-2/+4
Specialize query execution for incremental and non-incremental This specializes query execution for incremental and non-incremental by passing in a separate `dyn QueryEngine` types, taking advantage of the virtual dispatch to avoid a branch. This ends up duplicating `try_execute_query`, hopefully the compile time cost of that is relatively low. This is a performance improvement for the non-incremental path: <table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.8420s</td><td align="right">1.8331s</td><td align="right"> -0.48%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2652s</td><td align="right">0.2631s</td><td align="right"> -0.78%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">1.0161s</td><td align="right">1.0062s</td><td align="right"> -0.98%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.6408s</td><td align="right">1.6197s</td><td align="right">💚 -1.28%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">6.3939s</td><td align="right">6.3558s</td><td align="right"> -0.60%</td></tr><tr><td>Total</td><td align="right">11.1580s</td><td align="right">11.0780s</td><td align="right"> -0.72%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9918s</td><td align="right"> -0.82%</td></tr></table> The incremental path is more neutral: <table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check:initial</td><td align="right">2.2210s</td><td align="right">2.2227s</td><td align="right"> 0.08%</td></tr><tr><td>🟣 <b>hyper</b>:check:initial</td><td align="right">0.3441s</td><td align="right">0.3443s</td><td align="right"> 0.05%</td></tr><tr><td>🟣 <b>regex</b>:check:initial</td><td align="right">1.2919s</td><td align="right">1.2877s</td><td align="right"> -0.33%</td></tr><tr><td>🟣 <b>syn</b>:check:initial</td><td align="right">2.0749s</td><td align="right">2.0721s</td><td align="right"> -0.14%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check:initial</td><td align="right">7.9266s</td><td align="right">7.9206s</td><td align="right"> -0.07%</td></tr><tr><td>Total</td><td align="right">13.8585s</td><td align="right">13.8474s</td><td align="right"> -0.08%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9992s</td><td align="right"> -0.08%</td></tr></table> r? `@cjgillot`
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-3/+3
2023-05-14Specialize query execution for incremental and non-incrementalJohn Kåre Alsaker-2/+4
2023-04-30Use dynamic dispatch for queriesJohn Kåre Alsaker-19/+182
2023-04-26Remove QueryEngine traitJohn Kåre Alsaker-15/+15
2023-04-06Address commentsJohn Kåre Alsaker-5/+4
2023-04-06Erase query cache valuesJohn Kåre Alsaker-2/+12
2023-03-29Stabilize a portion of 'once_cell'Trevor Gross-1/+0
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-03-21AsLocalKey traitMichael Goulet-1/+1
2023-03-11Ensure value is on the on-disk cache before returning.Camille GILLOT-0/+1
2023-02-16Move provider fields back to rustc_query_implJohn Kåre Alsaker-1/+1
2023-02-16Factor query arena allocation out from query cachesJohn Kåre Alsaker-2/+4
2023-01-02Abolish `QueryVTable` in favour of more assoc items on `QueryConfig`Nilstrieb-1/+0
This may introduce additional mono _but_ may help const fold things better and especially may help not constructing a `QueryVTable` anymore which is cheap but not free.
2022-11-24Unsupported query error now specifies if its unsupported for local or ↵Sarthak Singh-2/+1
external crate
2022-11-24Auto merge of #103808 - cjgillot:vec-cache, r=TaKO8Kibors-2/+1
Use an IndexVec to cache queries with index-like key Revival of an old idea. Let's see if it has more effect. r? `@ghost`
2022-11-05Merge `QueryDescription` into `QueryConfig`Nilstrieb-1/+1
`QueryDescription` has gone through a lot of refactoring and doesn't make sense anymore.
2022-11-01Move keys module.Camille GILLOT-2/+1
2022-10-14Get rid of `rustc_query_description!`Nilstrieb-10/+1
Queries can provide an arbitrary expression for their description and their caching behavior. Before, these expressions where stored in a `rustc_query_description` macro emitted by the `rustc_queries` macro, and then used in `rustc_query_impl` to fill out the methods for the `QueryDescription` trait. Instead, we now emit two new modules from `rustc_queries` containing the functions with the expressions. `rustc_query_impl` calls these functions now instead of invoking the macro. Since we are now defining some of the functions in `rustc_middle::query`, we now need all the imports for the key types there as well.
2022-09-25Use function pointers instead of macro-unrolled loops in rustc_query_implJoshua Nelson-0/+2
By making these standalone functions, we a) allow making them extensible in the future with a new `QueryStruct` b) greatly decrease the amount of code in each individual function, avoiding exponential blowup in llvm
2022-09-09Remove unnecessary `TRY_LOAD_FROM_DISK` constantJoshua Nelson-1/+0
2022-09-09Don't create a new `try_load_from_disk` closure for each queryJoshua Nelson-1/+2
Instead, define a single function, parameterized only by the return type.
2022-09-06Make `HandleCycleError` an enum instead of a macro-generated closureJoshua Nelson-3/+0
- Add a `HandleCycleError` enum to rustc_query_system, along with a `handle_cycle_error` function - Move `Value` to rustc_query_system, so `handle_cycle_error` can use it - Move the `Value` impls from rustc_query_impl to rustc_middle. This is necessary due to orphan rules.
2022-08-24Simplify the syntax for macros generated by `rustc_queries`Joshua Nelson-1/+1
- Disallow multiple macros callbacks in the same invocation. In practice, this was never used. - Remove the `[]` brackets around the macro name - Require an `ident`, not an arbitrary `tt`
2022-08-23Move most of `make_query` into a generic function, away from the macroJoshua Nelson-1/+0
This should both make the code easier to read and also greatly reduce the amount of codegen the compiler has to do, since it only needs to monomorphize `create_query_frame` for each new key and not for each query.
2022-08-23Remove `$tcx` metavariable from `rustc_query_append`Joshua Nelson-1/+1
It's not actually necessary and it makes the code harder to read.
2022-08-18Add diagnostic translation lints to crates that don't emit them5225225-0/+2
2022-07-20consistently use VTable over Vtable (matching stable stdlib API RawWakerVTable)Ralf Jung-1/+1
2022-06-29get rid of `tcx` in deadlock handler when parallel compilationSparrowLii-0/+2
2022-06-08Use delayed error handling for `Encodable` and `Encoder` infallible.Nicholas Nethercote-0/+1
There are two impls of the `Encoder` trait: `opaque::Encoder` and `opaque::FileEncoder`. The former encodes into memory and is infallible, the latter writes to file and is fallible. Currently, standard `Result`/`?`/`unwrap` error handling is used, but this is a bit verbose and has non-trivial cost, which is annoying given how rare failures are (especially in the infallible `opaque::Encoder` case). This commit changes how `Encoder` fallibility is handled. All the `emit_*` methods are now infallible. `opaque::Encoder` requires no great changes for this. `opaque::FileEncoder` now implements a delayed error handling strategy. If a failure occurs, it records this via the `res` field, and all subsequent encoding operations are skipped if `res` indicates an error has occurred. Once encoding is complete, the new `finish` method is called, which returns a `Result`. In other words, there is now a single `Result`-producing method instead of many of them. This has very little effect on how any file errors are reported if `opaque::FileEncoder` has any failures. Much of this commit is boring mechanical changes, removing `Result` return values and `?` or `unwrap` from expressions. The more interesting parts are as follows. - serialize.rs: The `Encoder` trait gains an `Ok` associated type. The `into_inner` method is changed into `finish`, which returns `Result<Vec<u8>, !>`. - opaque.rs: The `FileEncoder` adopts the delayed error handling strategy. Its `Ok` type is a `usize`, returning the number of bytes written, replacing previous uses of `FileEncoder::position`. - Various methods that take an encoder now consume it, rather than being passed a mutable reference, e.g. `serialize_query_result_cache`.
2022-06-03Fully stabilize NLLJack Huey-1/+0
2022-05-21Auto merge of #97239 - jhpratt:remove-crate-vis, r=joshtriplettbors-1/+0
Remove `crate` visibility modifier FCP to remove this syntax is just about complete in #53120. Once it completes, this should be merged ASAP to avoid merge conflicts. The first two commits remove usage of the feature in this repository, while the last removes the feature itself.
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-1/+0
2022-05-13Cache more queries on disk.Camille GILLOT-1/+1
2022-02-25Switch bootstrap cfgsMark Rousskov-1/+1
2022-02-17Remove SimpleDefKindMark Rousskov-2/+0
2022-02-09Auto merge of #93741 - Mark-Simulacrum:global-job-id, r=cjgillotbors-0/+1
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-08Switch QueryJobId to a single global counterMark Rousskov-0/+1
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-06Delete query statsMark Rousskov-3/+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
2021-12-14Remove `in_band_lifetimes` from `rustc_query_impl`LegionMammal978-1/+0
See #91867 for more information.
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-1/+0