Skip to content

Implement rustc_datastructures::RwLock as union over RefCell and parking_lot::RwLock.#159452

Open
LorrensP-2158466 wants to merge 2 commits into
rust-lang:mainfrom
LorrensP-2158466:rwlock-single-threaded
Open

Implement rustc_datastructures::RwLock as union over RefCell and parking_lot::RwLock.#159452
LorrensP-2158466 wants to merge 2 commits into
rust-lang:mainfrom
LorrensP-2158466:rwlock-single-threaded

Conversation

@LorrensP-2158466

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

Copy link
Copy Markdown
Contributor

Revive of #136772.

cc "Parallel Rustc Front-end" #113349

Instead of explicit enums I decided to see what would happen if we would use the ModeUnion with Mode. Nothing changes API wise, but perf may or may not improve.

Second commit shows what actually changes, first commit just moves RwLock to a separate module.

…ot::RwLock`.

Implementation uses the same technique as with `Lock` by using a C enum together with a union around the locking primitives.
@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 17, 2026
@rustbot

rustbot commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 74 candidates
  • Random selection from 18 candidates

@petrochenkov

petrochenkov commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

#158845 replaces more cells with rwlocks, so the results for this PR should look more contrast if we benchmark it after landing that PR.

@petrochenkov

Copy link
Copy Markdown
Contributor

Can't look at the diff rn, need to go, but @bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 17, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 17, 2026
Implement `rustc_datastructures::RwLock` as union over `RefCell` and `parking_lot::RwLock`.
@LorrensP-2158466

Copy link
Copy Markdown
Contributor Author

#113349 replaces more cells with rwlocks, so the results for this PR should look more contrast if we benchmark it after landing that PR.

Understood, but you linked the tracking issue. Do you happen to have the link to the pr in question?

@rust-bors

rust-bors Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 57bfc2b (57bfc2bb07a49fc7e0c070fc155c156857526ca6)
Base parent: 4a9d536 (4a9d5368df6450bbd2fc8dde4508c3e5d83bb19d)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (57bfc2b): 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 rustc-perf
@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
Regressions ❌
(secondary)
0.1% [0.1%, 0.2%] 2
Improvements ✅
(primary)
-0.2% [-0.2%, -0.2%] 5
Improvements ✅
(secondary)
-0.4% [-0.7%, -0.2%] 8
All ❌✅ (primary) -0.2% [-0.2%, -0.2%] 5

Max RSS (memory usage)

Results (primary 2.0%, secondary 9.6%)

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

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

Cycles

Results (primary 2.2%, secondary -3.6%)

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

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

Binary size

Results (primary 0.1%, secondary 0.1%)

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

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.1%] 55
Regressions ❌
(secondary)
0.1% [0.0%, 0.1%] 23
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [0.0%, 0.1%] 55

Bootstrap: 491.028s -> 491.544s (0.11%)
Artifact size: 389.42 MiB -> 389.67 MiB (0.06%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jul 17, 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-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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants