Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate committed Jul 25, 2024
1 parent eef38b8 commit 1781dda
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 27 deletions.
32 changes: 11 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ hyper-util = { version = "0.1.3", features = ["tokio"] }
tokio = { version = "1", features = ["full", "macros"] }
reqwest = "0.12.4"

divan = "0.1.11"
divan = "0.1.14"

[[bench]]
name = "batch"
Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# futures-buffered

This project provides a single future structure: `FuturesUnorderedBounded`.
This project provides several future structures, all based around the `FuturesUnorderedBounded` primtive.

Much like [`futures::FuturesUnordered`](https://docs.rs/futures/0.3.25/futures/stream/struct.FuturesUnordered.html), this is a thread-safe, `Pin` friendly, lifetime friendly, concurrent processing stream.

The is different to `FuturesUnordered` in that `FuturesUnorderedBounded` has a fixed capacity for processing count. This means it's less flexible, but produces better memory efficiency.
This primtive is different to `FuturesUnordered` in that `FuturesUnorderedBounded` has a fixed capacity for processing count. This means it's less flexible, but produces better memory efficiency.

However, we also provide a `FuturesUnordered` which allocates larger `FuturesUnorderedBounded`
automatically to mitigate these inflexibilities. This is based on a triangular-array concept
to amortise the cost of allocating (much like with a Vec) without violating `Pin` constraints.

## Benchmarks

Expand All @@ -13,8 +17,9 @@ The is different to `FuturesUnordered` in that `FuturesUnorderedBounded` has a f
Running 65536 100us timers with 256 concurrent jobs in a single threaded tokio runtime:

```
FuturesUnordered time: [420.47 ms 422.21 ms 423.99 ms]
FuturesUnorderedBounded time: [366.02 ms 367.54 ms 369.05 ms]
FuturesUnorderedBounded [339.9 ms 364.7 ms 380.6 ms]
futures::FuturesUnordered [377.4 ms 391.4 ms 406.3 ms]
[min mean max]
```

### Memory usage
Expand Down Expand Up @@ -80,7 +85,7 @@ for _ in 0..128 {
```

```rust
use futures::future::join_all;
use futures_buffered::join_all;

async fn foo(i: u32) -> u32 { i }

Expand Down

0 comments on commit 1781dda

Please sign in to comment.