Skip to content

Resolver: Wrap arenas in WorkerLocal#159019

Open
LorrensP-2158466 wants to merge 1 commit into
rust-lang:mainfrom
LorrensP-2158466:worker-local-arenas
Open

Resolver: Wrap arenas in WorkerLocal#159019
LorrensP-2158466 wants to merge 1 commit into
rust-lang:mainfrom
LorrensP-2158466:worker-local-arenas

Conversation

@LorrensP-2158466

@LorrensP-2158466 LorrensP-2158466 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

In preperation of parallel import resolution #158845 this pr wraps the resolver arenas in WorkerLocal to ensure we don't need any synchronization to access an arena. This is common in the compiler.

r? @petrochenkov

@rustbot rustbot added 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 Jul 9, 2026
@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_resolve/src/build_reduced_graph.rs
let prefix = Segment::names_to_string(&prefix);
self.r.dcx().span_err(
use_tree.span(),
format!("cannot resolve a prelude import `{prefix}`: {path_res:?}"),

@petrochenkov petrochenkov Jul 9, 2026

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.

There's a CI failure due to this change.
Also {path_res:?} is leaking internal debug output into a user-visible message.

View changes since the review

let key =
BindingKey::new_disambiguated(ident, ns, || (child_index + 1).try_into().unwrap());
if resolutions
.entry(key)

@petrochenkov petrochenkov Jul 9, 2026

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.

Can use insert here, we are always adding a new entry, there's a span_bug check for this below.

View changes since the review

.entry(key)
.or_insert_with(|| self.arenas.alloc_name_resolution(orig_ident_span))
.borrow_mut_unchecked() // only 1 thread builds extern tables
.non_glob_decl

@petrochenkov petrochenkov Jul 9, 2026

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.

non_glob_decl can be set immediately after the resolution is created with alloc_name_resolution.

And if we hand-roll alloc_name_resolution we can even avoid borrow_mut_unchecked here.

View changes since the review

@petrochenkov

Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer

Copy link
Copy Markdown
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 9, 2026
@rust-bors

rust-bors Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

⌛ Trying commit 4e7b0b3 with merge 8921b29

To cancel the try build, run the command @bors try cancel.

Workflow: https://github.com/rust-lang/rust/actions/runs/29032517142

rust-bors Bot pushed a commit that referenced this pull request Jul 9, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

The PR description needs an update, it's not only about arenas.
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 9, 2026
@rustbot

rustbot commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

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

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-perf Status: Waiting on a perf run to be completed. 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