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

Add select_biased! macro #1040

Merged
merged 5 commits into from
May 19, 2024
Merged

Conversation

ryoqun
Copy link
Contributor

@ryoqun ryoqun commented Nov 25, 2023

(this is a draft; there's too much of code duplication...)

much like rust-lang/futures-rs#1976, i want biased select in crossbeam-channel as well. :)

@ryoqun
Copy link
Contributor Author

ryoqun commented Nov 25, 2023

@taiki-e

thanks for maintaining this crate. :)

i'll group my gentle reminders with this single comment. but, I'd want some initial feedback for following draft prs. if there's some hope for merging them, I'll finish off these to cross the line, very happily:

@ryoqun
Copy link
Contributor Author

ryoqun commented Jan 9, 2024

@taiki-e hey, thanks for active crossbeam maintenance. could you give this pr a initial assessment whether this pr can be merge or not ever? like other my prs, I'd like all of them to be merged eventually in some way...

thanks in advance.

@taiki-e
Copy link
Member

taiki-e commented May 2, 2024

Sorry for the slow response, I thought this was a patch that was 1k lines of complex implementation without any tests or documentation.

I would like to merge this once the tests and documentation indicating that this is properly biased have been added, and eliminated duplicate code by something like passing a bool literal to an internal macro.

@ryoqun ryoqun force-pushed the biased-channel-select branch from d37a73a to 364bda6 Compare May 4, 2024 09:00
@ryoqun
Copy link
Contributor Author

ryoqun commented May 4, 2024

@taiki-e

Sorry for the slow response

no problem. i really thanks for replying!

I thought this was a patch that was 1k lines of complex implementation without any tests or documentation.

sorry for confusion... I meant this is just pre-rfc api addition with copy-paste impl by marking it as draft pr... but i lacked explicit explanation...

I would like to merge this ...

super cool!! I just wanted to confirm that this api addition isn't controversial as much as other prs... ;)

... once the tests and documentation indicating that this is properly biased have been added, and eliminated duplicate code by something like passing a bool literal to an internal macro.

I've just done all the above after rebased. Also marked it as ready for review. :) Thanks in advance.

@ryoqun ryoqun marked this pull request as ready for review May 4, 2024 09:04
@@ -943,6 +943,39 @@ fn fairness_send() {
assert!(hits.iter().all(|x| *x >= COUNT / 4));
}

#[test]
fn unfairness() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i omitted more test cases like send one. let me know if i need to add more...

macro_rules! select_biased {
($($tokens:tt)*) => {
{
const _IS_BIASED: bool = true;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this was easiest way to implement... but this is accessible to user code. however, it seems we have precedent: _LEN.

@ryoqun
Copy link
Contributor Author

ryoqun commented May 4, 2024

I've just done all the above after rebased. Also marked it as ready for review. :) Thanks in advance.

sorry, i pushed more to fix bugs since this comment...

Copy link
Member

@taiki-e taiki-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @ryoqun!

@ryoqun
Copy link
Contributor Author

ryoqun commented May 14, 2024

@taiki-e Really and really thanks for approving this pr. Then, is this pr in a kind of internal testing now before merging? Also, do i need to add entries to crossbeam-channel/CHANGELOG.md via separate pr? I'm not sure the release process of crossbeam-channel... Anyway, I'm very looking forward to seeing my first pr for the crossbeam project to be shipped. :)

@taiki-e
Copy link
Member

taiki-e commented May 14, 2024

is this pr in a kind of internal testing now before merging

CI is failing on the master branch (mostly due to rust-lang/rust#124800) and we need to fix that before merging PRs...
https://github.com/crossbeam-rs/crossbeam/actions/runs/9072283469

@ryoqun
Copy link
Contributor Author

ryoqun commented May 14, 2024

is this pr in a kind of internal testing now before merging

CI is failing on the master branch (mostly due to rust-lang/rust#124800) and we need to fix that before merging PRs... https://github.com/crossbeam-rs/crossbeam/actions/runs/9072283469

Thanks for the quick reply. hmm, that's quite unfortunate, considering this pr is so close to be shipped... I just skimmed over the rust issue and its background. That said, I wonder how soon this resolves upstream..

Maybe pinning to older nightly (nightly-2024-05-04 or earlier according to https://blog.rust-lang.org/2024/05/06/check-cfg.html) in crossbeam CI isn't a viable option?

@ryoqun
Copy link
Contributor Author

ryoqun commented May 15, 2024

we need to fix that before merging PRs...
https://github.com/crossbeam-rs/crossbeam/actions/runs/9072283469

@taiki-e fyi, i fixed that: #1109 :)

@taiki-e taiki-e merged commit c9c5b9c into crossbeam-rs:master May 19, 2024
23 checks passed
@ryoqun
Copy link
Contributor Author

ryoqun commented May 19, 2024

@taiki-e I'm really appreciate merging this pr (and the ci fix pr as well). seems the master branch ci is green as well. Now, the only thing I'm looking forward to is crossbeam-channel 0.5.13... sorry for asking too much :)

taiki-e pushed a commit that referenced this pull request May 19, 2024
taiki-e pushed a commit that referenced this pull request May 19, 2024
@taiki-e
Copy link
Member

taiki-e commented May 19, 2024

Published in crossbeam-channel 0.5.13.

@ryoqun
Copy link
Contributor Author

ryoqun commented May 22, 2024

@taiki-e hi, I'm reporting back with a good news. :) Really thanks to your collaboration with this pr shipped, using select_biased! resulted in 12-13% performance improvement: anza-xyz/agave#1437. and the pr just got merged there.

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.

2 participants