Skip to main content

Module fleet_pacing

Module fleet_pacing 

Source
Expand description

When each delivery of a broadcast starts (fleet::fleet_broadcast_impl).

A broadcast used to start a turn on every target in the same second. Each turn that starts in a pane on screen costs that windowโ€™s page a burst of work on its one thread, and sixteen of them in four seconds left the page drawing four or five frames a second (docs/reports/REPORT_UI_CHOP_ON_FLEET_BROADCAST_AND_UI_BUSY_METER_2026_11_19.md).

The starts are spread by what each one costs this AgentMux, as a token bucket: a small burst goes at once, the rest follow at a steady rate with a little jitter, and the whole spread has a ceiling. A broadcast to two agents is as fast as before; one to thirty takes a few seconds. A target that costs this AgentMux nothing (another machine, another channel) is never delayed, and a delivery that is slow or fails holds up no other: each starts at its own time.

Structsยง

Pace ๐Ÿ”’
One broadcastโ€™s pace: when each target starts, and who hears as each delivery ends.

Constantsยง

BURST ๐Ÿ”’
Cost that goes at once, before pacing begins: two panes on screen.
CEILING ๐Ÿ”’
The last delivery starts no later than this after the send: past it the gap shrinks instead.
COST_NONE ๐Ÿ”’
A target this AgentMux only hands on (another machine or channel), or one that has no route and fails at once.
COST_OFF_SCREEN ๐Ÿ”’
A turn that starts on this AgentMux in a pane no window is showing: the machine starts the work and the page gets its messages, but draws nothing.
COST_ON_SCREEN ๐Ÿ”’
A turn that starts in a pane a window of this AgentMux is showing: its page draws it.
GAP ๐Ÿ”’
The time one unit of cost takes after the burst: two and a half turn starts a second on screen, against the four a second that was too many.
JITTER ๐Ÿ”’
Each paced start moves by up to this share of its gap, either way, so the starts do not land on a fixed beat.
PROGRESS_ID_MAX ๐Ÿ”’
The longest progress_id a sender may give (a UUID is 36).

Functionsยง

blocks_on_screen ๐Ÿ”’
Those of block_ids a window of this AgentMux is showing: in the active tab of a workspace that a window has open.
costs_of ๐Ÿ”’
What each of targets costs this AgentMux: local holds the ones that start a turn here, on_screen those of them a window is showing.
noise_from ๐Ÿ”’
A repeatable stream of values in 0..1 from seed (splitmix64), for the jitter: a broadcastโ€™s own id seeds it, so no random source is needed.
pace_for ๐Ÿ”’
The pace for one broadcast to targets, of which local start a turn on this AgentMux. With a progress_id, each delivery that ends is published as fleetbroadcastprogress.
start_offsets ๐Ÿ”’
How long after the send each targetโ€™s delivery starts, in the order of costs (one per target, a COST_*). noise gives a value in 0..1 for each paced start; 0.5 is no jitter.

Type Aliasesยง

Progress ๐Ÿ”’
Told as each delivery ends: how many have ended, of how many.