Expand description
What a worker knows of master time (B225, B228): the leading master’s monotonic clock, on which every deadline the master and its workers must agree on is set.
Every master message carries the master’s clock (MasterClock): its timeline, master time
when it was sent, and the latest heartbeat the master had heard on this stream. That
heartbeat (or the Register, number 0) was sent before the message, so master time
master_ms happened after the worker sent it: master time X is reached no earlier than
the send time plus X - master_ms (Cristian’s bound), less what the two clocks’ rates may
differ by. The worker keeps the tightest such sample and decides by it, never by its own idea
of when the master sent something, and never by a wall clock.
The tightest sample is taken over a window (decision 447: 10 minutes by default): an older one, however tight, drifts its 0.1 % from further back.
The worker’s own clock is the one that keeps counting through a suspend (CLOCK_BOOTTIME):
one that stopped would make it late. A pause that stops even that one (a frozen VM) shows
as its wall clock running ahead of it, one machine’s two clocks compared: the worker then
counts any deadline as passed.
Structs§
- Last
Stamp - The latest master message’s stamp: its master time and wall clock, and when it arrived.
- Local
- The worker’s clocks at one moment.
- Master
Time - Master time as this worker knows it, for one session.
- Outbox
- What a session sent that the master hasn’t named as heard yet, and the latest of the
master’s messages it has handled (B240). Shared by
MasterTime, which reads the sends when a stamp names one, and the session’s sender, which numbers and stamps each message as it queues it. - Sample
Reading - What the best sample says now (for metrics, decision 448).
Constants§
- DEFAULT_
SAMPLE_ WINDOW - How far back the tightest sample is looked for (decision 447,
SCHEDR_HIDDEN__WORKER__MASTER_SAMPLE_WINDOW). - DEFAULT_
SKEW_ WARNING - The wall-clock difference from the master, beyond the round trip, that a worker warns
about (decision 449, B232;
SCHEDR_HIDDEN__WORKER__CLOCK_SKEW_WARNING). - SENT_
KEPT - At most so many messages wait to be heard of (the oldest dropped first): a session that silent has ended. Every message is numbered (B240), so it is bounded by what a session sends over a round trip; dropped, the master’s naming one finds nothing, and its cutoff counts from an earlier send (sooner, never later).
Functions§
- boot_
now - The boot clock: time since boot, suspend included. Linux’s
CLOCK_BOOTTIME; elsewhere (macOS)CLOCK_MONOTONIC, which counts a suspend there too. - lock
- The outbox, locked (a panic while it was held left nothing half-done that matters).
Type Aliases§
- Shared
Outbox - A session’s
Outbox, shared.