crossbeam
crossbeam copied to clipboard
Crossbeam channel slower than Go channels with input data delay
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.
I think it may be related to extra spinning. What about when using std::sync::mpsc?
What about when using std::sync::mpsc?
@taiki-e Also time close to crossbeam benchmark result but also twice slower than Go chan.
cc @ibraheemdev
@Jensanf do you have the numbers for the std version?
@ibraheemdev for std::sync::mpsc
Without delay: Mean: 3.972µs
With 100 microsecond delay: Mean: 11.984µs