-
TROPHIME Valentin authoredTROPHIME Valentin authored
README.md 1.69 KiB
Preemptive iterator
Prototype aiming to provide a simple interface to introduce preemptive iterator
for asynchronous Rust programs. Its purpose is to increase reactivity of
async fn
spending all of it's time in a long blocking loop task by simply
changing the final iterator method chains.
It provides the PreemptiveIterator
trait implemented for all standard Rust
types implementing core::iter::Iterator
. For the moment our trait provide only
fold, for_each
equivalent.
Overhead measurement
There is an example in examples/overhead.rs
you can try it with the following
command :
cargo run --release --example overhead -- --reactivity-us 10 --n-iter 100 --duration-us 1000
The arguments are :
- The number of iteration that you will perform.
- Duration is the time it takes for each iteration to perform.
- Reactivity is the targeted duration (in microseconds) between each
yield_now().await
inserted by our iterator.
Typical overhead values with a constant amount of work targeted of one seconds with no reactivity constraint :
Overhead | Task duration | N tasks | Reactivity |
---|---|---|---|
~ 1% | 10 ms | 100 | infinity |
~ 15% | 1 ms | 1000 | infinity |
~ 60% | 100 μs | 10000 | infinity |
~ 600% | 10 μs | 100000 | infinity |
TODO :
-
try_fold, try_for_each
(problem: genericTry
trait is unstable) all, any, collect, count, lt, ge, inspect, last, max, min
-
all, any
? -
collect, partition, unzip
? -
count, last
? -
ge, gt, le, lt, eq, ne
? -
min, max, min_by, max_by, min_by_key, max_by_key
? -
product, sum, reduce
? - Why so much overhead ?