Skip to content

Improve bounded MPSC throughput for inline 1 KiB messages #401

Open

Description

@tisonkun

The reproducible gap is four producers and one consumer on four Tokio runtime workers, using 64 queue slots. Each timed batch transfers 16,384 inline [u8; 1024] values. Both four-library launches put Asyncband fourth.

Apple M4 Max, macOS arm64, rustc 1.101.0-nightly. Each cell gives rank, elapsed time relative to Asyncband and the whole-batch median over 10 interleaved runs. Lower is faster. Ecosystem measurements

Scenario Fixed rounds Asyncband Tokio async-channel flume
Full suite, inline 1 KiB 26 #4, 1.00× (309 ms) #1, 0.25× (77 ms) #2, 0.40× (123 ms) #3, 0.85× (264 ms)
Focused repeat, inline 1 KiB 26 #4, 1.00× (306 ms) #1, 0.30× (91 ms) #2, 0.42× (129 ms) #3, 0.93× (284 ms)

With topology and batch count fixed, Asyncband and Tokio took 23 and 39 ms for usize, 304 and 78 ms for inline 1 KiB, and 106 and 89 ms for the same bytes in a Box. Calling reserve before every Asyncband send still took 303 ms for inline values. Stack samples showed mutex waits and memmove in the send path. In another matched run, changing only the internal lock reduced Asyncband from 306 to 189 ms, with Tokio at 83 ms. The queue moves values into and out of a shared VecDeque under its state lock.

First contribution

Reproduce the inline row, then profile send and receive separately with inline and boxed payloads. Look for copies or time under the queue lock. Validate a candidate with ordinary usize traffic, a full queue and cancelled reservations. Preserve delivery order, backpressure and the exact requested capacity.

cargo x bench --bench ecosystem -- mpsc/bounded/tasks-4p1c-cap64-4w-inline1k --rounds 26 --repeat 10 --raw

The one-producer usize case at capacity 1024 is a variability control at 430 fixed rounds. Flume won its original run (210 ms vs Asyncband's 366 ms), and Asyncband won the repeat (194 ms vs 213 ms). It has a different payload and topology. Both four-library rankings

Performance tracking issue #396

Activity

  1. nanami-0713 commented on Nov 10, 2026

    @nanami-0713
    Contributor

    Reproduced the inline row and the boxed control on Apple M5 (10 cores), macOS 27.0.1, rustc 1.99.1 stable, in a disposable checkout of b1354ae (current main), cargo x bench --bench ecosystem, --rounds 26 --repeat 10, medians with min..max.

    Payload Asyncband Tokio async-channel flume
    inline 1 KiB 264 ms (259..267) 87 ms (86..88) 157 ms (153..181) 273 ms (268..283)
    boxed 1 KiB 126 ms (123..128) 94 ms (94..95) 117 ms (102..129) 129 ms (126..137)

    The orderings differ from the issue's host only in the last two places: there flume was third and Asyncband fourth; here Asyncband is third (264 ms) and flume fourth (273 ms). With the payload boxed, the gap to Tokio narrows from 3.03x (264/87) to 1.34x (126/94), async-channel moves to 117 ms, and all four implementations land within 1.37x of Tokio (async-channel 1.24x, Asyncband 1.34x, flume 1.37x) — the same direction as the issue's own Box measurement (106 vs 89 ms on M4 Max).

    Two of the issue's other controls bracket this on its host: with usize payloads Asyncband took 23 ms against Tokio's 39, and switching only the internal lock moved the inline row from 306 to 189 ms with Tokio at 83 — that substitution alone recovers roughly half of the 306−83 ms gap; the issue's stack samples attribute much of the row's remaining time to memmove in the send path, under the queue lock.

    The in-tree commands used:

    cargo x bench --bench ecosystem -- mpsc/bounded/tasks-4p1c-cap64-4w-inline1k --rounds 26 --repeat 10 --raw
    cargo x bench --bench ecosystem -- mpsc/bounded/tasks-4p1c-cap64-4w-boxed1k --rounds 26 --repeat 10 --raw

    Performance tracking issue #396

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions