Skip to content

Break query cycles without spawning a separate thread#155927

Open
zetanumbers wants to merge 3 commits intorust-lang:mainfrom
zetanumbers:break_cycle_in_worker
Open

Break query cycles without spawning a separate thread#155927
zetanumbers wants to merge 3 commits intorust-lang:mainfrom
zetanumbers:break_cycle_in_worker

Conversation

@zetanumbers
Copy link
Copy Markdown
Contributor

@zetanumbers zetanumbers commented Apr 28, 2026

This PR removes separate thread for query cycle breaking. Essentially I made sure that behavior right before a block is done before deadlock handler is called.

TODO: explain in a comment that we use CurrentGcx in case worker thread no longer has any tasks to execute and triggers a deadlock handler, which means there's no ImplicitCtxt set to extract tcx from.

While this code is very unpolished at the moment and introduces some test failures due to diagnostics, it's a proof of concept and a place for feedback. I plan to make query cycle handling blocking of all worker threads in order to add something like a WorkerLocal::as_deadlocked to return every worker-local value in future. This is one of the stepping stones to remake query state hash table with QueryJob's into something more worker-thread-local.
Blocked on #155881.

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 28, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 28, 2026

r? @jackh726

rustbot has assigned @jackh726.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 21 candidates

@zetanumbers
Copy link
Copy Markdown
Contributor Author

r? @nnethercote

@rustbot rustbot assigned nnethercote and unassigned jackh726 Apr 28, 2026
@rust-log-analyzer

This comment has been minimized.

@Zoxc Zoxc mentioned this pull request Apr 29, 2026
@zetanumbers zetanumbers force-pushed the break_cycle_in_worker branch from 852f305 to b8788ce Compare April 30, 2026 11:08
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 30, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants