The fast sync and async channel that Rust deserves!
Kanal is a Rust library to help programmers design effective programs in the CSP model by providing featureful multi-producer multi-consumer channels. This library focuses on bringing both sync and async API together to unify message passing between sync and async parts of Rust code in a performant manner.
Kanal is in pre-release and should not be used in production yet.
Performance is the main goal of Kanal.
Close
function and you can broadcast that signal from any instance of the channel.Results are normalized based on Kanal sync results, so 60x means the test for that framework takes 60 times slower than Kanal.
Machine: AMD Ryzen Threadripper 2950X 16-Core Processor
Rust: rustc 1.65.0 (897e37553 2022-11-02)
Go: go version go1.19.3 linux/amd64
OS (uname -a
): Linux 5.15.0-52-generic #58~20.04.1-Ubuntu SMP Thu Oct 13 13:09:46 UTC 2022 x86_64
Date: Nov 11, 2022
It's because of Tokio's context-switching performance, like Golang, Tokio context-switch in the same thread to the next coroutine when the channel message is ready which is much cheaper than communicating between different threads. it's the same reason why async network applications usually perform better than sync implementations. As channel size grows you see better performance in sync benchmarks because channel sender threads can push their data directly to the channel queue and don't need to wait for signals from receivers threads.