Skip to content

Rust: Extract files in parallel following CODEQL_THREADS - #23324

Open
redsun82 wants to merge 8 commits into
redsun82-supreme-inventionfrom
redsun82-refactored-train
Open

redsun82 wants to merge 8 commits into
redsun82-supreme-inventionfrom
redsun82-refactored-train

Conversation

@redsun82

@redsun82 redsun82 commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 592a6fb66a9f43655b98d91ba97c12422dc597e3

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ Source TRAP and archives byte-identical at --threads 1 vs 8 on hello-workspace, a broken/loose-file project and dependency-features.
↑ New parallel-extraction test: cross-file calls, macro expansion and extraction steps identical at 1 and 4 threads in a local replay; dependency-features also runs both.
↑ The 10,000-term deep input runs only at 2 threads, so it stays on 16 MiB workers and off the 1 MiB Windows main thread.
↑ Worker stack overflow reproduced and fixed; the unit test aborts with a 2 MiB stack or when a single-item batch runs inline.
↑ Extractor unit tests now run in the rust-code CI job.
↑ CI green at 87d0e8a, including integration tests on all platforms.
↓ CI pending at this head. Earlier heads failed because the call query also ran over the deep input; that input now has its own test directory.
↓ .expected files written from a manual replay, not the pytest harness.
↓ Abort on worker spawn failure untested; no per-layer timing.

Second layer of the Rust extractor performance stack (on top of #23323). Extracts files in parallel, following the CLI's --threads (CODEQL_THREADS).

  • Each worker thread has its own Extractor and Semantics over a clone of the loaded database. The VFS, archiver and TRAP provider are shared, and worker steps are merged into the main extractor.
  • Applies to both the per-workspace source/dependency loop and the dependency-feature selection loop. The feature-selection bookkeeping (has_alternative/extracted) stays on the main thread, and results come back in input order.
  • The thread count is parsed with the shared parse_codeql_threads. Unlike the extractor spec default of -1, extraction stays sequential when CODEQL_THREADS is unset or invalid. With one thread everything runs on the current thread.
  • Workers get a 16 MiB stack, as rust-analyzer does: the default 2 MiB overflows on deeply nested code.
  • Per-step telemetry durations are summed across threads, so they can exceed the total.
  • If a worker panics, the other workers stop taking new files and the panic is re-raised.
  • Input files are deduplicated, because TRAP and archive writes for the same file must not run concurrently.

Crate-graph TRAP is unchanged. Its cfg-option order varies between runs, even sequential ones.

Each worker uses its own `Semantics` over a clone of the loaded database.
Extraction stays sequential when `CODEQL_THREADS` is unset or invalid.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@redsun82
redsun82 requested review from a team as code owners December 2, 2026 12:11
Copilot AI adaptive review requested due to automatic review settings December 2, 2026 12:11

This comment was marked as outdated.

@github-actions github-actions Bot added the Rust Pull requests that update Rust code label Dec 2, 2026
The default 2 MiB stack overflowed on deeply nested expressions that
extract fine on the main thread. Also test dependency features and a deep
expression with multiple threads, and make the panic test schedule-proof.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This comment was marked as outdated.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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

Automated tests do not verify multi-file semantic results across thread counts or confirm that the deep-expression fixture is actually extracted using the worker stack.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Test concurrent cross-file resolution and macro expansion

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

Please add an automated 1-versus-4-thread semantic-results test for a workspace with multiple source files. Each workspace in dependency-features has only one source file, so its source loop runs inline, while deep-expression checks only database creation. Consequently neither test checks cross-file resolution or macro expansion when source files are actually processed concurrently.

Medium severity Assert deep workspace files are extracted by worker stack

rust/​ql/​integration-tests/​deep-expression/​test_deep_expression.py:9

This only checks that database creation succeeds, so it also passes if deep.rs is skipped or the workspace falls back to sequential extraction. Please assert that deep.rs and another file were loaded with semantics and extracted, for example via ExtractorStep query results, so the test actually exercises the worker stack.

1 resolved since last review

Review effort: Max (adaptive)

Replace the deep-expression test with a workspace whose files call each
other and use a macro, comparing calls and extraction steps at 1 and 4
threads.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This comment was marked as outdated.

Run the deep-expression check in its own test at two threads, so it never
runs on the main thread (1 MiB on Windows), and so the call-parity query no
longer type-checks 10,000 additions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This comment was marked as outdated.

Every query in a test directory runs for each test there, so the deep input
also went through the call query. Give it a directory with just the
extraction step query.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This comment was marked as outdated.

A one-item batch was clamped to one thread and ran inline, missing the large
worker stack. Only run inline when one thread is requested.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This comment was marked as outdated.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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

Human assessment is needed because the tests do not cover repeated or aliased input paths, leaving deduplication safeguards against concurrent output writes unverified.

No open issues 🎉

1 resolved since last review

Review effort: Max (adaptive)

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