Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

channel: Replace Spinlock with Mutex #835

Merged
merged 1 commit into from May 23, 2022
Merged

channel: Replace Spinlock with Mutex #835

merged 1 commit into from May 23, 2022

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented May 22, 2022

Addresses one of @thomcc's reviews in rust-lang/rust#93563 (comment) (sorry for the late response!)

Historically, the use of spinlock was introduced when the dependency on parking_lot was removed (5208895).
However, given that it is used in Waker, which includes vectors that may be reallocated, using mutex seems to be the right choice here.

r? @ibraheemdev
bors d=ibraheemdev

@bors
Copy link
Contributor

bors bot commented May 22, 2022

✌️ ibraheemdev can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@ibraheemdev
Copy link
Contributor

ibraheemdev commented May 22, 2022

A better design might be to use an intrusive linked list for wakers, which could avoid allocations entirely in the critical section, but this seems like a good change either way. Thanks!

@ibraheemdev
Copy link
Contributor

@bors r+

@taiki-e
Copy link
Member Author

taiki-e commented May 23, 2022

bors r=ibraheemdev

(The command of bors used in rust-lang is @bors, but the command of bors-ng used in the community is bors)

@bors
Copy link
Contributor

bors bot commented May 23, 2022

Build succeeded:

@bors bors bot merged commit 78b7ac3 into master May 23, 2022
@bors bors bot deleted the taiki-e/mutex branch May 23, 2022 02:06
bors bot added a commit that referenced this pull request Jun 16, 2022
850: Prepare for the next release r=taiki-e a=taiki-e

- crossbeam-channel 0.5.4 -> 0.5.5
  - Replace Spinlock with Mutex. (#835)
- crossbeam-epoch 0.9.8 -> 0.9.9
  - Replace lazy_static with once_cell. (#817)
- crossbeam-utils 0.8.8 -> 0.8.9
  - Replace lazy_static with once_cell. (#817)

Co-authored-by: Taiki Endo <te316e89@gmail.com>
bors bot added a commit that referenced this pull request Jun 16, 2022
850: Prepare for the next release r=taiki-e a=taiki-e

- crossbeam-channel 0.5.4 -> 0.5.5
  - Replace Spinlock with Mutex. (#835)
- crossbeam-epoch 0.9.8 -> 0.9.9
  - Replace lazy_static with once_cell. (#817)
- crossbeam-utils 0.8.8 -> 0.8.9
  - Replace lazy_static with once_cell. (#817)

Co-authored-by: Taiki Endo <te316e89@gmail.com>
ti-chi-bot added a commit to tikv/tikv that referenced this pull request Nov 17, 2022
close #13815

According to crossbeam-rs/crossbeam#835, spinning at the
sending side is probably a bad idea because of large critical section and it's
fixed in the recent version.

This commit updates crossbeam-channel. It will reduce CPU usage a bit and
improve performance.

Signed-off-by: Yilin Chen <sticnarf@gmail.com>

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants