Skip to content

Rust: Test stateful proc macros under parallel extraction - #23333

Open
redsun82 wants to merge 3 commits into
redsun82-congenial-potatofrom
redsun82-turbo-garbanzo
Open

redsun82 wants to merge 3 commits into
redsun82-congenial-potatofrom
redsun82-turbo-garbanzo

Conversation

@redsun82

@redsun82 redsun82 commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 3d17a2400083818bf742985ff86285b83922222f

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ Pinned rust-analyzer 0.0.358 pool serializes requests per process and routes to the least-loaded live one.
↑ Unit test pins pool size for 0/1/2/4/32 threads; fails if hardcoded back to 1.
↑ path-resolution results identical at 1 and 8 threads (1 vs 4 server processes, none left over).
↓ No benchmark of this layer alone; proc-macro QL tests not re-run on this exact head; CI pending.
↑ Restacked unchanged onto L3 4d971dc (L2 CI step plus L3 log wording only); fmt, clippy and 23/23 unit tests pass on this head.
↓ CI on this head pending.

Stacked on #23330.

Adds an integration test for stateful proc macros, such as enum_dispatch, that keep process-global state across expansions, under parallel extraction. This layer originally sized a pool of proc-macro servers from the extraction threads, but rust-analyzer spreads expansions over the pool, so such macros lost generated impls (five on fuel-core). Extraction keeps a single proc-macro server. The test lost impls in every pooled run at 8 threads.

Dropping the pool cost little in paired 8-thread runs: no measurable difference on ripgrep, and about 4% extractor wall time on tokio.

@redsun82
redsun82 requested review from a team as code owners December 2, 2026 14:56
Copilot AI adaptive review requested due to automatic review settings December 2, 2026 14:56
@github-actions github-actions Bot added the Rust Pull requests that update Rust code label Dec 2, 2026

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

Running up to four proc-macro processes per workspace changes expansion concurrency and replicates dylib memory, requiring broader validation of correctness and resource use.

No open issues 🎉

What changed in this PR

Sizes the Rust extractor’s proc-macro server pool to support parallel extraction while limiting memory overhead.

Changes:

  • Pass the extraction thread count into configuration creation.
  • Clamp the pool size to 1–4 processes.
File Description
rust/​extractor/​src/​main.rs Passes extraction threads into configuration creation.
rust/​extractor/​src/​config.rs Sizes and caps the proc-macro server pool.

Review effort: Max (adaptive)

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.

🟡 Changes recommended

Tests do not verify pool sizing for 1, 2, and >4 threads or macro expansion with multiple servers, allowing a regression to one process to go undetected.

1 open issue

Review effort: Max (adaptive)

Comment thread rust/extractor/src/config.rs Resolved

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

Moving to multiple proc-macro processes changes execution isolation and scheduling while multiplying dylib memory use, exceeding the limited-consequence approval scope.

No open issues 🎉

1 resolved since last review

Review effort: Balanced (adaptive)

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

Concurrent proc-macro expansion across up to four server processes changes process-local state sharing and multiplies dylib memory use, requiring runtime validation beyond a limited-scope review.

No open issues 🎉

Review effort: Max (adaptive)

@redsun82
redsun82 requested an adaptive review from Copilot December 4, 2026 16:42
@redsun82 redsun82 changed the title Rust: Size the proc-macro server pool from the extraction threads Rust: Test stateful proc macros under parallel extraction Dec 4, 2026

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

Assessing sensitivity to server-pool regressions requires deeper analysis of interacting dependency-order priming, concurrent proc-macro requests, and process-global expansion state.

No open issues 🎉

Review effort: Balanced (adaptive)

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.

🟡 Changes recommended

The validation narrative contradicts the reviewed one-server configuration and cites a unit test absent from the referenced code.

1 open issue

Review effort: Max (adaptive)

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 regression fixture requires integration validation and human review because its reliability depends on timing-sensitive interactions between parallel priming, process-global macro state, and proc-macro server scheduling.

No open issues 🎉

1 resolved since last review

Review effort: Max (adaptive)

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 regression test’s scheduling-sensitive interactions with proc-macro state, server routing, and expansion caching require human review to confirm it reliably detects the original race.

No open issues 🎉

Review effort: Max (adaptive)

Paolo Tranquilli and others added 3 commits December 4, 2026 18:22
Parallel extraction workers otherwise all queue on a single proc-macro
server. Use up to four server processes, as each loads every proc-macro
dylib.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Stateful proc macros like `enum_dispatch` keep process-global state
across expansions, so spreading expansions over a pool of servers can
lose generated items. Add an integration test exercising this pattern
under parallel extraction.

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

The regression test’s timing-sensitive concurrency and proc-macro scheduling require runtime validation to establish reliable coverage, but the integration test was not run on this head.

No open issues 🎉

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