Repository navigation
Backlog
Labels
Description
Summary
Under load, the owner executor is the bottleneck of local dispatch, and much of its time goes into the kernel to sleep and be woken. Each settled call sends its own task to the owner. When the owner is asleep, each of those tasks costs a futex wake on the worker side and a futex wait on the owner side. Batching the completions that are ready into one owner task, so that one wake drains many, is the remaining lever on throughput.
Evidence (measured)
- Setup: 64 calls in flight, 8 pool workers, owner on its own thread.
- Measured with
perf record --call-graph dwarf, x86-64 Linux, Release.
| Calls/s | Owner thread, share of all samples | Owner thread, kernel | Kernel share of the owner | |
|---|---|---|---|---|
| Before #1176 | ~63k | 43.68% | 30.21% | 69% |
| After #1176 (pool spins 25 µs) | ~211k | 42.24% | 12.43% | 29% |
- Before perf: cheaper local dispatch, linear handler teardown, observability build switch #1176, where the owner's kernel time went: about 31% in
futex_wakeand 30% infutex_wait. - Bare cross-thread hop: a condition-variable ping-pong with no morph code costs 8.4 µs. That is the floor a call that sleeps cannot beat.
- What perf: cheaper local dispatch, linear handler teardown, observability build switch #1176 fixed, and what it left: the pool spin removed most worker-side sleeps. The owner still sleeps between bursts, and it still handles one completion per task.
Not verified
- What the remaining 29% is. It was not broken down by kernel symbol after perf: cheaper local dispatch, linear handler teardown, observability build switch #1176. Whether it is still mostly futex traffic is inferred from the before profile, not measured.
- Whether batching recovers it. That was not prototyped. With one call in flight there is nothing to batch, so single-call latency would not improve. Only concurrent load can gain.
- Owner executors other than a thread blocked on a condition variable. The Qt event loop,
MainThreadExecutorand the WASM main thread wake differently and were not profiled.
Direction
- Completions from pool workers go into a per-owner MPSC queue. Only the transition from empty to non-empty posts one drain task to the owner, which settles everything queued.
- Invariants to keep: settle order per handler, owner affinity of
Completion, and.thenattached on the owner. - This changes how
Completionreaches the owner, so the relevant spec pages (docs/spec/core/bridge.md,backend.md,executor.md) come first.
What would change the verdict
- Close if a kernel-symbol breakdown after perf: cheaper local dispatch, linear handler teardown, observability build switch #1176 shows that the owner's remaining kernel time is not wake and wait traffic.
- Close if a prototype at 64 in flight moves throughput by less than about 10%.
- Re-scope to the owner executor itself if, for example, a short spin in
runUntilgets the same gain with no change to settle order.
Activity