Coder Social home page Coder Social logo

kanal's Introduction

Kanal

The fast sync and async channel that Rust deserves!

Crates.io Documentation MIT licensed

What is Kanal

Kanal is a Rust library to help programmers design effective programs in CSP model via 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.

Why Kanal is faster?

  1. Kanal is using direct memory access to copy objects from stack of the sender or write to stack of the receiver exactly the same as Golang, this eliminates any heap allocation need for bounded(0) channels and also reduce stack allocation substantially too.
  2. Kanal is using specially tuned mutex for its channel lock, it is possible because channel internal lock time is predictable. That said the mutex is implemeneted with eventual fairness.
  3. Rust amazing compiler

Why to use Kanal?

  • Kanal is super fast and efficient in communication
  • Kanal can communicate in both sync and async and even between sync and async
  • Kanal provide cleaner API in comparison with other rust libraries
  • Like Golang you have access to Close function and you can broadcast that signal from any instance of the channel.

Why not to use Kanal?

  • We are trying our best to audit our small codebase and make sure there is no undefined behavior. Kanal is using Unsafe. If you are not ok with that in your project we suggest using safe-only alternatives.

Benchmark Results

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 rustc 1.64.0
Go: go version go1.19.2 linux/amd64
OS (uname -a): Linux 5.13.0-35-generic #40~20.04.1-Ubuntu SMP Mon Mar 7 09:18:32 UTC 2022 x86_64
Date: Oct 16, 2022

Benchmark codes

Benchmarks

kanal's People

Contributors

fereidani avatar hauvgaard avatar adrian-budau avatar zzau13 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.