hanabi1224 / Programming-Language-Benchmarks

Yet another implementation of computer language benchmarks game
https://programming-language-benchmarks.vercel.app/
MIT License
638 stars 134 forks source link

Coroutine based coro-prime-sieve for Rust #279

Open DXist opened 2 years ago

DXist commented 2 years ago

Rust has an unstable feature for generators/semicoroutines - https://doc.rust-lang.org/beta/unstable-book/language-features/generators.html

It's interesting to see how it will compare to async based implementations.

hanabi1224 commented 2 years ago

Generators are coroutines w/o schedulers, aka semicoroutines. I don't think it's a good idea to mix them up in a single problem, we can maybe define another one for generators

DXist commented 2 years ago

An interesting detail.

I renamed "coroutines" into "semicoroutines".

So coroutine based prime sieve is expected to reveal the overhead of coroutine scheduler, isn't it?

Separate generator focused problem will be fair in this case.

DXist commented 2 years ago

Also for couroutines it's interesting to compare single threaded and multi-threaded schedulers.

Lua scheduler is single threaded. Tokio in Rust is multi-threaded by default but can be configured to use only current thread.

In this case there is no need to use atomic primitives and pay for cross cpu synchronization.

hanabi1224 commented 2 years ago

it's interesting to compare single-threaded and multi-threaded schedulers

I believe this has already been covered. e.g. 3.rs for single-threaded tokio, 3-m.rs for multi-threaded tokio, 1.kt for single-threaded kotlin coroutine, 2-m.kt for multi-threaded kotlin coroutine, etc.

DXist commented 2 years ago

Indeed, didn't notice that