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

Crossbeam channel slower than Go channels with input data delay #1029

Open
Jensanf opened this issue Oct 6, 2023 · 5 comments
Open

Crossbeam channel slower than Go channels with input data delay #1029

Jensanf opened this issue Oct 6, 2023 · 5 comments

Comments

@Jensanf
Copy link

Jensanf commented Oct 6, 2023

Description:

Hello,
I've been evaluating methods for fast data transfer between threads in Rust. After benchmark tests, I found that the crossbeam_channel appeared to be the most efficient mechanism in Rust, even outperforming Go channels on initial tests.
However, when introducing data with a delay, I observed that crossbeam_channel was significantly slower than Go channels.

Code:

Link to my Rust test code
Link to my Go test code

Benchmark Results:

Rust crossbeam:

    Without delay: Mean: 1.369µs
    With 100 microsecond delay: Mean: 11.246µs

Go channels:

    Without delay: Mean: 34.192µs
    With 100 microsecond delay: Mean: 5.92µs

Test Environment:

Crossbeam Version: 0.8
Machine: AMD Ryzen 7 5800H
Rust Version: rustc 1.72.0 (5680fa18f 2023-08-23)
Go Version: go1.21.1 linux/amd64

Is there a known reason for this behavior? I would like to understand if there's a way to reduce the delay on data transfer between channels in crossbeam or if there are recommended practices for managing when data has delays.

Thank you for your insights.

@taiki-e
Copy link
Member

taiki-e commented Oct 6, 2023

I think it may be related to extra spinning. What about when using std::sync::mpsc?

@Jensanf
Copy link
Author

Jensanf commented Oct 9, 2023

What about when using std::sync::mpsc?

@taiki-e Also time close to crossbeam benchmark result but also twice slower than Go chan.

@taiki-e
Copy link
Member

taiki-e commented Oct 9, 2023

cc @ibraheemdev

@ibraheemdev
Copy link
Contributor

@Jensanf do you have the numbers for the std version?

@Jensanf
Copy link
Author

Jensanf commented Oct 25, 2023

@ibraheemdev for std::sync::mpsc

 Without delay: Mean: 3.972µs
 With 100 microsecond delay: Mean: 11.984µs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants