Call completion ring¶
Calls between process cells need a bounded path with cost independent of the number of calls already completed. Each admitted shared-memory channel has one call ring and one completion ring. The caller monitor and owner monitor use those rings as single-producer, single-consumer queues while the nucleus keeps authority, credit and terminality. This page covers the physical layout, publication protocol, notification, correlation and failure behaviour.
Ring structure¶
flowchart LR
subgraph CALLER["CALLER MONITOR"]
direction TB
CP["Call producer"]
CC["Completion consumer"]
end
subgraph PAIR["CHANNEL EPOCH MAPPINGS"]
direction TB
CALL[("Call ring<br/>bounded SPSC")]
COMPLETE[("Completion ring<br/>bounded SPSC")]
end
subgraph OWNER["OWNER MONITOR"]
direction TB
OC["Call consumer"]
OP["Completion producer"]
end
CP -->|"release publication"| CALL
CALL -->|"acquire observation"| OC
OP -->|"release publication"| COMPLETE
COMPLETE -->|"acquire observation"| CC
Call producer is the only writer of call publication state, and Call
consumer is the only writer of call release state. The completion ring uses
the inverse ownership. Each direction remains single-producer and
single-consumer across separate monitor processes.
Each backing starts with two 64-byte control cache lines and continues with fixed 160-byte slots:
| Region | Contents |
|---|---|
| Producer cache line | Ring generation, producer position, publication eventcount, layout version |
| Consumer cache line | Consumer position, release eventcount, invalidation bit |
| Slot | 8-byte sequence, 128-byte compact header, 24-byte inline payload |
Capacity is a power of two from 2 through 4096. The channel retires before a 64-bit sequence can overflow. Larger payloads use the Bulk attachment lane.
Publication and observation¶
stateDiagram-v2
[*] --> free
free --> written: producer owns the expected sequence
written --> published: release-store sequence
published --> observed: consumer acquire-loads sequence
observed --> free: consumer release-stores next reuse sequence
The producer admits every frame and confirms capacity before writing slot
bytes. A batch publishes only when every slot in the batch is available. The
consumer observes a slot only after its sequence carries the expected
published value. It validates magic, version, kind, flags, grant slot and
generation, channel epoch, correlation, the closed kernel operation family,
ordinals, deadline, lengths and counts before admitting the payload. A call
must name one of capability, resource, stream, buffer, Run or
Session; a completion carries an empty operation family and empty call
routing fields. It releases the slot and advances the consumer position only
after both the frame and receiving-end correlation guards accept it.
A malformed or correlation-invalid published slot invalidates its ring. The consumer position and slot release sequence stay unchanged, and the monitor reports the applicable typed malformed-frame or unmatched-correlation fact. Subsequent use observes peer closure.
Notification and backpressure¶
Monitors sleep on the publication and release counters and are woken by the other side, so an idle channel consumes no CPU and a published frame is seen without a polling delay. Call and byte authority come from the nucleus grant.
A full call ring or completion ring produces the transport-neutral
backpressure fault. Publication leaves correlation state untouched. Ring
capacity leaves granted credit unchanged: the caller presents a reservation
for one call and the exact attachment byte count from the nucleus-owned
delegated-credit state.
See Credit backpressure.
Correlation and terminal paths¶
The compact header carries a fixed domain-separated correlation derived from
AttemptId. The caller retains the exact AttemptId while its call is
pending. The owner retains an opaque observation token after accepting the
call, and only that token can publish the matching completion. Cancellation
removes the pending call; a later completion becomes an unmatched-correlation
fact while credit remains settled exactly once.
When that late completion matches a bounded tombstone for an already terminal attempt, the consumer releases its slot, reports the unmatched-correlation fact as drained and continues with later completions. A correlation that matches neither pending work nor a terminal tombstone invalidates the ring.
An accepted completion returns the exact caller-owned AttemptId from the
pending table alongside its frame. An endpoint
that lacks the corresponding pending-table entry reports an opaque attempt
digest as transport-local correlation evidence.
Pending and observed correlations are bounded by nucleus credit. Completed correlation tombstones are bounded by physical ring capacity, so monitor memory stays bounded through sustained wraparound. On invalidation, each monitor can project its still-pending and already-observed work for nucleus settlement.
Failure boundaries¶
Bytes written before release publication are invisible to the consumer. A producer death in that interval leaves a reserved attempt for nucleus reconciliation. After the owner observes a call, the observation remains the dispatch boundary used to classify owner death. Channel invalidation wakes both publication and capacity waiters and maps further access to the typed peer-closed outcome.
The authenticated reference channel remains the lifecycle and fault lane. The ring changes byte movement within a live channel epoch. Tasks, attempts, grants, handles, credit and evidence authority remain nucleus-owned. See The memory model and Semantic equivalence.
A resource call is admitted and published by the caller monitor in one operation, and the caller settles its reservation in the same operation that collects the completion. The owner monitor keeps admitting commands and interruptions while provider work is pending, so a cancellation reaches a busy cell.