Skip to content

Bring WaitGroup completion to parity with waitgroup #397

Open

Description

@tisonkun

Completing a group with one pending observer took nearly three times as long as waitgroup 0.1.2 in the original comparison. Both adapters create a group, register the observer, drop the worker handles and poll to completion. The four-worker case drops four handles sequentially on the same thread.

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 waitgroup
One worker, one observer 3,500,000 #2, 1.00× (284 ms) #1, 0.35× (98 ms)
Four workers, one observer 2,600,000 #2, 1.00× (305 ms) #1, 0.44× (134 ms)

The baseline maintains a participant count as well as Arc ownership. Even the first observer uses a locked, cancellable waker collection. A candidate shares allocation ownership across participants, stores the first waker inline and uses the collection for additional observers. In two launches the one-worker medians were 81 vs 97 ms and 86 vs 97 ms (Asyncband vs waitgroup). With four workers they were 119 vs 125 ms and 127 vs 124 ms. That ranking changed between launches. Candidate and raw samples in PR #395

First contribution

Run the command on 36ba6f2 and on the candidate in #395 on the same machine. Report the two completion rows on independent launches, ideally also on Linux. The candidate adds a four-observer drain case. Check its before/after result separately because its peers compose a different multi-observer mechanism.

cargo x bench --bench ecosystem -- waitgroup/ --repeat 10 --raw

The goal is repeatable parity or better on both original rows while preserving completion visibility, independent observers, cancellation and wakeups. Measurements and correctness review on #395 are both welcome.

Performance tracking issue #396

Activity

  1. rokadepiyush49-rgb commented on Nov 6, 2026

    @rokadepiyush49-rgb

    Could you assign this to me? I'd run waitgroup/ on 36ba6f2 and the #395 head on an Apple M4 (10 cores, macOS 27.0.1), with independent launches, then repeat on Linux. I'd report the two completion rows and the four-observer drain separately.

    From #395's table, complete-4-workers is the row that's still behind (135 vs 127 ms), so I'd start there.

    One question: waiters.rs uses RwLock only for writes. In a small standalone probe on this Mac, a fresh Mutex allocated 64 bytes on first lock and a fresh RwLock didn't. Was that the reason for choosing it?

    I haven't run the benchmarks yet. I used Claude to help me read the code and write the probe.

  2. tisonkun commented on Nov 6, 2026

    @tisonkun
    MemberAuthor

    Thanks for your interest! We don't assign issues to individual contributors. Anyone is welcome to submit a PR directly for review.

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