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

This comment has been minimized.

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

This comment has been minimized.

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.

@rust-bors

rust-bors Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 8921b29 (8921b29e422cc22127146a787dda0186d080d041)
Base parent: 561ea2b (561ea2bfa3022226082e2db39d6ccb241e9e34bc)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (8921b29): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.3% [0.3%, 0.3%] 2
Regressions ❌
(secondary)
0.3% [0.1%, 0.6%] 16
Improvements ✅
(primary)
-0.4% [-0.5%, -0.4%] 6
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.1%] 6
All ❌✅ (primary) -0.2% [-0.5%, 0.3%] 8

Max RSS (memory usage)

Results (primary 1.9%, secondary 1.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.9% [1.9%, 1.9%] 1
Regressions ❌
(secondary)
6.2% [6.2%, 6.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.7% [-3.7%, -3.7%] 1
All ❌✅ (primary) 1.9% [1.9%, 1.9%] 1

Cycles

Results (primary -3.0%, secondary -3.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.0% [-3.0%, -3.0%] 1
Improvements ✅
(secondary)
-3.0% [-3.0%, -3.0%] 1
All ❌✅ (primary) -3.0% [-3.0%, -3.0%] 1

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 489.147s -> 488.199s (-0.19%)
Artifact size: 388.47 MiB -> 388.92 MiB (0.12%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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