Skip to content

[pull] master from TimelyDataflow:master - #108

Merged
pull[bot] merged 1 commit into
SINHASantos:masterfrom
TimelyDataflow:master
Sep 5, 2026
Merged

pull[bot] merged 1 commit into
SINHASantos:masterfrom
TimelyDataflow:master

Conversation

@pull

@pull pull Bot commented Sep 5, 2026

Copy link
Copy Markdown

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 : )

…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>
@pull pull Bot locked and limited conversation to collaborators Sep 5, 2026
@pull pull Bot added the ⤵️ pull label Sep 5, 2026
@pull
pull Bot merged commit 6a0ffa8 into SINHASantos:master Sep 5, 2026
3 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant