[pull] master from TimelyDataflow:master - #108
Merged
Merged
Conversation
…s, serialize broadcasts once (#816) * Poll for events before parking an idle worker Parking a thread and waking it again costs one to four microseconds on common platforms, and a worker with nothing to do parked immediately. For tightly coupled workers, such as a barrier per loop iteration, that wake latency was nearly the whole per-iteration cost. A worker now polls its channels for a bounded time before parking, set by `WorkerConfig::idle_spin` (default 10 microseconds, `--idle-spin` on the command line). Polling occupies a core, so the duration bounds the CPU an idle worker burns each time it goes idle; zero restores the previous behavior. The event-surfacing prologue of `step_or_park` is factored into `poll_events` so the polling loop can reuse it. On an M4 with four workers, examples/barrier.rs went from 2.5 to 1.3 microseconds per iteration, and from 3.1 to 0.8 with two. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QDsLC46QQW9aBrksaWad6T * Do not signal a flush that enqueues nothing The counting pushers announced every push, including the `None` that flushes a channel, although the wrapped pushers are unbuffered and a `None` enqueues nothing. For the cross-thread pusher this cost an events message and an unpark per peer per flush, and `Progcaster::send` flushes after every broadcast, so each progress update woke every peer twice. Receivers then sorted and deduplicated twice the events. With workers polling before they park this was about 18% of a four-worker barrier iteration. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QDsLC46QQW9aBrksaWad6T * Route a worker's own messages through a thread-local queue The intra-process allocator gave a worker an mpsc pusher to itself, so a message to self cost two cross-thread sends, a self-unpark, and two cross-thread receives. The self pusher is now a thread-local channel, and `LocalFirst` drains it ahead of the shared receiver. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QDsLC46QQW9aBrksaWad6T * Serialize broadcasts once for local peers in the zero-copy allocator `TcpAllocator::broadcast` already serialized a message once per remote process and let the receiving process share the bytes among its workers, but the intra-process allocator inherited the default `broadcast`, which serialized once per local peer. `ProcessAllocator` now implements `broadcast`: one pusher serializes into a staging buffer whose target, `Fanout`, hands each other worker a clone of the `Bytes` handle through that worker's own send endpoint, via the new `SendEndpoint::push_bytes`. Going through the destination's endpoint keeps per-destination ordering and runs its spill policy as before. The worker's own copy stays typed, through a thread-local queue, which is acceptable for progress messages as they are small and never worth paging out; data channels keep the shared byte queue for self-sends. With four workers and `--zerocopy`, examples/barrier.rs went from 1.57 to 1.34 microseconds per iteration. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QDsLC46QQW9aBrksaWad6T * Check the deserialized size of Bincode messages only in debug builds `Bincode::from_bytes` re-serialized the payload it had just deserialized to check its length, a full traversal of every received message, including data containers. The check is kept under `debug_assertions`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QDsLC46QQW9aBrksaWad6T --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )