Skip to content

perf: fix Notify race in writable backpressure #119

Description

@Yanstart

Context

Adversarial review found that Notify::notify_one() has a race condition: if fired before the receiver calls notified().await, the notification is lost. The sender then falls back to a 5-second sleep (WRITABLE_FALLBACK_SECS), causing throughput stalls.

Fix (two changes)

  1. Replace notify_one() with notify_waiters() for writable notifications in client.rs and server.rs
  2. Reduce WRITABLE_FALLBACK_SECS from 5 to 0.1 (100ms) as safety net

Files

  • crates/quick-transport/src/client.rs — writable notifier.notify_one() → notify_waiters()
  • crates/quick-transport/src/server.rs — same
  • bins/quick-entry/src/tunnel.rs — WRITABLE_FALLBACK_SECS 5 → Duration::from_millis(100)
  • bins/quick-exit/src/tunnel.rs — same

Acceptance Criteria

  • notify_waiters() used for all writable notifications
  • Fallback timeout reduced to 100ms
  • No 5-second stalls in iperf3 per-second output
  • 351+ tests pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceThroughput and latency optimizations

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions