Skip to content

std: use sync::RwLock for internal statics#100581

Merged
bors merged 1 commit into
rust-lang:masterfrom
joboet:sync_rwlock_everywhere
Sep 21, 2022
Merged

std: use sync::RwLock for internal statics#100581
bors merged 1 commit into
rust-lang:masterfrom
joboet:sync_rwlock_everywhere

Conversation

@joboet

@joboet joboet commented Aug 15, 2022

Copy link
Copy Markdown
Member

Since sync::RwLock is now const-constructible, it can be used for internal statics, removing the need for sys_common::StaticRwLock. This adds some extra allocations on platforms which need to box their locks (currently SGX and some UNIX), but these will become unnecessary with the lock improvements tracked in #93740.

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Aug 15, 2022
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @m-ou-se

(rust-highfive has picked a reviewer for you, use r? to override)

@rustbot

rustbot commented Aug 15, 2022

Copy link
Copy Markdown
Collaborator

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 15, 2022
@thomcc

thomcc commented Sep 18, 2022

Copy link
Copy Markdown
Member

I'm not a fan of making this change (or the one in #100579). Can we instead change StaticMutex/StaticRwlock to use the locks internally on platforms where that impl isn't worse?

@thomcc

thomcc commented Sep 18, 2022

Copy link
Copy Markdown
Member

It looks like we use this for the environment lock, and for the panic hook. I don't really feel like either of these are likely to be hot enough for the extra allocation to matter, so I'm not sure how much I actually care here now that I look.

r? @thomcc

@rust-highfive rust-highfive assigned thomcc and unassigned m-ou-se Sep 18, 2022
@thomcc

thomcc commented Sep 18, 2022

Copy link
Copy Markdown
Member

This looks fine. This does actually introduce a branch even on OSes with the good locks (due to the poison error handling). I doubt it matters but is probably worth preventing a rollup as a result.

@bors r+ rollup=never

@bors

bors commented Sep 18, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit 25cc0ce3c3eed6278bdeed9eddca8dc43ea55002 has been approved by thomcc

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 18, 2022
@bors

bors commented Sep 18, 2022

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 25cc0ce3c3eed6278bdeed9eddca8dc43ea55002 with merge 0f66914ea522ad0920154b14127447512a361cf0...

@bors

bors commented Sep 18, 2022

Copy link
Copy Markdown
Collaborator

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 18, 2022
@rust-log-analyzer

This comment has been minimized.

@thomcc

thomcc commented Sep 19, 2022

Copy link
Copy Markdown
Member

@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 Sep 19, 2022
@joboet joboet force-pushed the sync_rwlock_everywhere branch from 25cc0ce to be09a4a Compare September 19, 2022 21:27
@joboet

joboet commented Sep 19, 2022

Copy link
Copy Markdown
Member Author

@rustbot ready

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

thomcc commented Sep 19, 2022

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Sep 19, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit be09a4a has been approved by thomcc

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 19, 2022
@thomcc

thomcc commented Sep 19, 2022

Copy link
Copy Markdown
Member

And for good measure,

@bors delegate+

@bors

bors commented Sep 19, 2022

Copy link
Copy Markdown
Collaborator

✌️ @joboet can now approve this pull request

@bors

bors commented Sep 20, 2022

Copy link
Copy Markdown
Collaborator

⌛ Testing commit be09a4a with merge 4456640f3e841eacc29fc3ecd88718c03bd0fcce...

@bors

bors commented Sep 20, 2022

Copy link
Copy Markdown
Collaborator

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 20, 2022
@joboet

joboet commented Sep 20, 2022

Copy link
Copy Markdown
Member Author

That looks like a spurious failure...
@bors r=thomcc

@bors

bors commented Sep 20, 2022

Copy link
Copy Markdown
Collaborator

💡 This pull request was already approved, no need to approve it again.

@bors

bors commented Sep 20, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit be09a4a has been approved by thomcc

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 20, 2022
@bors

bors commented Sep 20, 2022

Copy link
Copy Markdown
Collaborator

⌛ Testing commit be09a4a with merge 7743aa8...

@bors

bors commented Sep 21, 2022

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: thomcc
Pushing 7743aa8 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 21, 2022
@bors bors merged commit 7743aa8 into rust-lang:master Sep 21, 2022
@rustbot rustbot added this to the 1.66.0 milestone Sep 21, 2022
@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (7743aa8): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-5.3% [-5.3%, -5.3%] 1
Improvements ✅
(secondary)
-2.8% [-3.5%, -1.5%] 3
All ❌✅ (primary) -5.3% [-5.3%, -5.3%] 1

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.3% [-2.5%, -2.0%] 2
All ❌✅ (primary) - - 0

Footnotes

  1. the arithmetic mean of the percent change 2

  2. number of relevant changes 2

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@joboet joboet deleted the sync_rwlock_everywhere branch September 21, 2022 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants