about summary refs log tree commit diff
path: root/compiler/rustc_query_system/src/query
AgeCommit message (Collapse)AuthorLines
2025-07-28Auto merge of #144469 - Kivooeo:chains-cleanup, r=SparrowLiibors-4/+4
Some `let chains` clean-up Not sure if this kind of clean-up is welcoming because of size, but I decided to try out one r? compiler
2025-07-28use let chains in mir, resolve, targetKivooeo-4/+4
2025-07-24Use LocalKey<Cell> methods moreCameron Steffen-2/+2
2025-07-05use `is_multiple_of` instead of manual moduloFolkert de Vries-1/+1
2025-06-11Use `rustc_thread_pool` instead of `rustc-rayon-core`Celina G. Val-5/+5
2025-05-14Handle `rustc_query_system` cases of `rustc::potential_query_instability` lintismailarilik-0/+4
2025-04-29Add some commentsJohn Kåre Alsaker-0/+2
2025-04-29Add a jobserver proxy to ensure at least one token is always heldJohn Kåre Alsaker-6/+10
2025-03-26Use a function to create `QueryStackDeferred` to ensure context is CopyJohn Kåre Alsaker-3/+7
2025-03-26Avoiding calling queries when collecting active queriesJohn Kåre Alsaker-100/+213
2025-03-25Rollup merge of #138874 - Zoxc:waiter-race, r=SparrowLii,davidtwcoJacob Pratt-25/+12
Batch mark waiters as unblocked when resuming in the deadlock handler This fixes a race when resuming multiple threads to resolve query cycles. This now marks all threads as unblocked before resuming any of them. Previously if one was resumed and marked as unblocked at a time. The first thread resumed could fall asleep then Rayon would detect a second false deadlock. Later the initial deadlock handler thread would resume further threads. This also reverts the workaround added in https://github.com/rust-lang/rust/pull/137731. cc `@SparrowLii` `@lqd`
2025-03-25Rollup merge of #138581 - Zoxc:abort-handler-if-locked, r=SparrowLiiMatthias Krüger-4/+12
Abort in deadlock handler if we fail to get a query map Resolving query cycles requires the complete active query map, or it may miss query cycles. We did not check that the map is completely constructed before. If there is some error collecting the map, something has gone wrong already. This adds a check to abort/panic if we fail to construct the complete map. This can help differentiate errors from the `deadlock detected` case if constructing query map has errors in practice. An `Option` is not used for `collect_active_jobs` as the panic handler can still make use of a partial map.
2025-03-24Remove `QueryWaiter::notify`John Kåre Alsaker-8/+2
2025-03-24Batch mark waiters as unblocked when resuming in the deadlock handlerJohn Kåre Alsaker-2/+8
2025-03-24Revert "resume one waiter at a call"John Kåre Alsaker-15/+2
This reverts commit cc1e4ede9388d87750c3751f41e8c6c4f6cae995.
2025-03-21Address commentsJohn Kåre Alsaker-4/+8
2025-03-21Optimize hash map operations in the query systemJohn Kåre Alsaker-29/+41
2025-03-21Update commentsJohn Kåre Alsaker-0/+3
2025-03-21Abort in deadlock handler if we fail to get a query mapJohn Kåre Alsaker-4/+5
2025-03-14Rename `QuerySideEffects` to `QuerySideEffect`John Kåre Alsaker-11/+15
2025-03-14Represent diagnostic side effects as dep nodesJohn Kåre Alsaker-74/+31
2025-03-10Convert `ShardedHashMap` to use `hashbrown::HashTable`Josh Stone-10/+4
The `hash_raw_entry` feature has finished fcp-close, so the compiler should stop using it to allow its removal. Several `Sharded` maps were using raw entries to avoid re-hashing between shard and map lookup, and we can do that with `hashbrown::HashTable` instead.
2025-03-05Rollup merge of #137731 - SparrowLii:waiter, r=nnethercote许杰友 Jieyou Xu (Joe)-2/+15
Resume one waiter at once in deadlock handler When multiple query loop errors occur in the code, only one waiter should be resumed at a time to avoid waking up multiple waiters at the same time and causing deadlock due to thread grabbing. This fixes the UI failures in #132051 cc `@Zoxc` `@cjgillot` `@nnethercote` `@bjorn3` `@Kobzol` Zulip discussion [here](https://rust-lang.zulipchat.com/#narrow/channel/187679-t-compiler.2Fwg-parallel-rustc/topic/Deadlocks.20and.20Rayon) Edit: We can't reproduce these bugs with the existing test suits, so we keep them until we merge #132051 UPDATES #129912 UPDATES #120757 UPDATES #129911
2025-03-05resume one waiter at a callroot-2/+15
2025-03-03Remove some unnecessary aliases from `rustc_data_structures::sync`Zalathar-1/+1
With the removal of `cfg(parallel_compiler)`, these are always shared references and `std::sync::OnceLock`.
2025-02-16Move hashes from rustc_data_structure to rustc_hashes so they can be shared ↵Ben Kimock-1/+1
with rust-analyzer
2025-02-03Notes on types/traits used for in-memory query cachingZalathar-5/+23
When the word "cache" appears in the context of the query system, it often isn't obvious whether that is referring to the in-memory query cache or the on-disk incremental cache. For these types, we can assure the reader that they are for in-memory caching.
2025-01-16Properly note when query stack is being cut offMichael Goulet-3/+3
2025-01-07don't return an Option from try_find_dep_kindMartin Zacho-3/+3
2025-01-06improve diagnostics for const eval query overflowMartin Zacho-10/+8
2024-12-13Rename ty_def_id so people will stop using it by accidentMichael Goulet-3/+3
2024-12-04Make sure to record deps from cached task in new solver on first runMichael Goulet-3/+5
2024-11-19Auto merge of #124780 - Mark-Simulacrum:lockless-cache, r=lcnrbors-62/+32
Improve VecCache under parallel frontend This replaces the single Vec allocation with a series of progressively larger buckets. With the cfg for parallel enabled but with -Zthreads=1, this looks like a slight regression in i-count and cycle counts (~1%). With the parallel frontend at -Zthreads=4, this is an improvement (-5% wall-time from 5.788 to 5.4688 on libcore) than our current Lock-based approach, likely due to reducing the bouncing of the cache line holding the lock. At -Zthreads=32 it's a huge improvement (-46%: 8.829 -> 4.7319 seconds). try-job: i686-gnu-nopt try-job: dist-x86_64-linux
2024-11-15Improve VecCache under parallel frontendMark Rousskov-62/+32
This replaces the single Vec allocation with a series of progressively larger buckets. With the cfg for parallel enabled but with -Zthreads=1, this looks like a slight regression in i-count and cycle counts (<0.1%). With the parallel frontend at -Zthreads=4, this is an improvement (-5% wall-time from 5.788 to 5.4688 on libcore) than our current Lock-based approach, likely due to reducing the bouncing of the cache line holding the lock. At -Zthreads=32 it's a huge improvement (-46%: 8.829 -> 4.7319 seconds).
2024-11-12Delete the `cfg(not(parallel))` serial compilerNoratrieb-62/+15
Since it's inception a long time ago, the parallel compiler and its cfgs have been a maintenance burden. This was a necessary evil the allow iteration while not degrading performance because of synchronization overhead. But this time is over. Thanks to the amazing work by the parallel working group (and the dyn sync crimes), the parallel compiler has now been fast enough to be shipped by default in nightly for quite a while now. Stable and beta have still been on the serial compiler, because they can't use `-Zthreads` anyways. But this is quite suboptimal: - the maintenance burden still sucks - we're not testing the serial compiler in nightly Because of these reasons, it's time to end it. The serial compiler has served us well in the years since it was split from the parallel one, but it's over now. Let the knight slay one head of the two-headed dragon!
2024-10-28fix clippy::clone_on_ref_ptr for compilerklensy-1/+1
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-5/+5
2024-08-19Prevent double panic in query system, improve diagnosticsFelix Rath-2/+9
2024-08-02chore: use shorthand initializerYuri Astrakhan-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-41/+40
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-2/+2
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-04-30Remove `extern crate tracing` from numerous crates.Nicholas Nethercote-0/+1
2024-04-29Remove `extern crate rustc_macros` from numerous crates.Nicholas Nethercote-0/+1
2024-04-06Remove sharding for VecCacheMark Rousskov-13/+6
This sharding is never used (per the comment in code). If we re-add sharding at some point in the future this is cheap to restore, but for now no need for the extra complexity.
2024-03-26Remove `CacheSelector` trait now that we can use GATsOli Scherer-43/+1
2024-03-09Some tweaks to the parallel query cycle handlerJohn Kåre Alsaker-16/+8
2024-03-02Don't panic when waiting on poisoned queriesJohn Kåre Alsaker-3/+2
2024-02-29Overhaul how stashed diagnostics work, again.Nicholas Nethercote-2/+1
Stashed errors used to be counted as errors, but could then be cancelled, leading to `ErrorGuaranteed` soundness holes. #120828 changed that, closing the soundness hole. But it introduced other difficulties because you sometimes have to account for pending stashed errors when making decisions about whether errors have occured/will occur and it's easy to overlook these. This commit aims for a middle ground. - Stashed errors (not warnings) are counted immediately as emitted errors, avoiding the possibility of forgetting to consider them. - The ability to cancel (or downgrade) stashed errors is eliminated, by disallowing the use of `steal_diagnostic` with errors, and introducing the more restrictive methods `try_steal_{modify,replace}_and_emit_err` that can be used instead. Other things: - `DiagnosticBuilder::stash` and `DiagCtxt::stash_diagnostic` now both return `Option<ErrorGuaranteed>`, which enables the removal of two `delayed_bug` calls and one `Ty::new_error_with_message` call. This is possible because we store error guarantees in `DiagCtxt::stashed_diagnostics`. - Storing the guarantees also saves us having to maintain a counter. - Calls to the `stashed_err_count` method are no longer necessary alongside calls to `has_errors`, which is a nice simplification, and eliminates two more `span_delayed_bug` calls and one FIXME comment. - Tests are added for three of the four fixed PRs mentioned below. - `issue-121108.rs`'s output improved slightly, omitting a non-useful error message. Fixes #121451. Fixes #121477. Fixes #121504. Fixes #121508.
2024-02-28Rename `DiagnosticBuilder` as `Diag`.Nicholas Nethercote-4/+4
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.
2024-02-28Rename `Diagnostic` as `DiagInner`.Nicholas Nethercote-3/+3
I started by changing it to `DiagData`, but that didn't feel right. `DiagInner` felt much better.