Skip to content

Rust: Prime crate def maps in dependency order before parallel extraction - #23330

Open
redsun82 wants to merge 4 commits into
redsun82-refactored-trainfrom
redsun82-congenial-potato
Open

redsun82 wants to merge 4 commits into
redsun82-refactored-trainfrom
redsun82-congenial-potato

Conversation

@redsun82

@redsun82 redsun82 commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 4d971dc48efe73338ce9a423533166d6d0d603a4

Dimension Assessment Rationale
Change confidence 8/10 ↑ Unit tests cover the dependency closure, scheduling order, empty graph, cycles, panic propagation (mutation-checked) and real parallelism (22/22, repeated).
↑ QL subset at 4 threads and a 10k-term deep-expression database create --threads=2 pass; all extractor-tests passed before the rebase.
↓ Crate seeding from a real partial workspace is not tested; speedup of this layer alone not benchmarked; CI pending.
↑ Restacked onto L2 b2ac40c: run_on_threads takes the inline decision before clamping, so singleton batches in both parallel_map and dependency-order priming run on a large-stack worker; fmt, clippy and 22/22 unit tests pass on this head.
↓ QL and integration tests not re-run on this exact head; CI pending.
↑ Restacked onto L2 592a6fb (CI-only change) with the wording-only def-map priming log fix; range-diff otherwise identical; fmt, clippy and 22/22 unit tests pass on this head.
↓ QL and integration tests not re-run on this exact head; CI pending.

Stacked on #23324. Before parallel extraction of the main workspace, computes the def maps of the crates being extracted and their dependencies on the worker threads, in crate-graph dependency order, so workers don't block on the same salsa queries.

  • New parallel::for_each_in_dependency_order scheduler; spawning shares layer 2's sized-stack helper (run_on_threads) with parallel_map.
  • Skipped with one thread, and not done in the dependency loop.
  • Panics while priming are swallowed: the same def map is recomputed and fails as before during extraction. A worker panic in the scheduler stops other workers and propagates.
  • Timing is an info! log rather than an extraction step, to keep extractor_steps output unchanged.

@redsun82
redsun82 requested review from a team as code owners December 2, 2026 13:57
Copilot AI adaptive review requested due to automatic review settings December 2, 2026 13:57

This comment was marked as outdated.

@redsun82
redsun82 requested an adaptive review from Copilot December 2, 2026 14:13
@github-actions github-actions Bot added the Rust Pull requests that update Rust code label Dec 2, 2026

This comment was marked as outdated.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The scheduler unnecessarily wakes all idle workers on serial dependency chains and treats failed def-map queries as successful, triggering costly retries across dependent crates.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Skip dependents of failed def-map queries

rust/​extractor/​src/​main.rs:295

A failed def-map query is reported to the scheduler as a successful completion, so it starts all of that crate's dependents. If those crates need the failed map, each retries the same failing query and emits another panic before extraction can retry it; a widely shared dependency can therefore turn one failure into many expensive retries. Please mark failed nodes and skip their dependents during priming, while leaving extraction to retry them as intended.

Medium severity Wake only workers needed for newly ready nodes

rust/​extractor/​src/​parallel.rs:182

On a long dependency chain, each completion makes only one node ready, but this wakes every idle worker to compete for the mutex. With many extraction threads that produces up to one wakeup per worker per crate on the serial critical path. Please wake workers only for newly ready nodes, and broadcast when aborting or when no work remains.

1 resolved since last review

Review effort: Max (adaptive)

This comment was marked as outdated.

Paolo Tranquilli and others added 4 commits December 3, 2026 10:17
…tion

With more than one extraction thread, compute all crate def maps of a
freshly loaded workspace in dependency order on that many threads. Otherwise
extraction workers compute them lazily and mostly serialize on them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5d1bdb3a2b3c43ce80bf533edd8fc893
Also synchronize the panic test on worker unwinding instead of a sleep.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5d1bdb3a2b3c43ce80bf533edd8fc893
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5d1bdb3a2b3c43ce80bf533edd8fc893
The count includes crates whose def map failed or was skipped in a cycle.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5d1bdb3a2b3c43ce80bf533edd8fc893
@redsun82
redsun82 force-pushed the redsun82-congenial-potato branch from b7d03ca to 4d971dc Compare December 3, 2026 10:18
@redsun82
redsun82 requested an adaptive review from Copilot December 3, 2026 10:19

This comment was marked as outdated.

This branch has not been deployed

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

Labels

Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants