Skip to main content

Module wire

Module wire 

Source
Expand description

PERF-7: the item path — each item encoded once, straight into the frame its socket writes. PERF-7: the item path — an item encoded once, by its method’s own event type, straight into a buffer its socket writes from.

whenthen
a method yields an event under the WebSocket pipe (pipe)wrap_stream serializes it once, by its own Serialize, into the pipe’s buffer (a block from its connection’s pool); the Data item carries it as Content — JSON bytes, no Value
the pipe’s buffer takes an event’s JSON (json, PERF-34)written by a real scan, not a byte at a time, the bytes serde_json writes
the same event anywhere else (in process, a nested route, a test)it becomes a Value as before: in-process items stay what they cost
a transformer reads a Data item’s contentContent decodes its bytes once, on demand (Deref to Value); one that rewrites it replaces the whole Content — an encoded item is a Data item, so no rewrite can miss one (PERF-17’s finding: the gated view’s rewrite did)
the pipe writes an itemthe notification’s prefix (once a call), the metadata (once a stream), the content type and the content’s bytes, and the suffix, into the same buffer: one frame, split off as Bytes (no allocation while the block has room)
the transport offers a FrameSink (plexus-transport’s socket loop)the frame goes to the socket’s writer as it is; the call’s first frame is fenced, so it follows the subscription’s answer that jsonrpsee queued
it does not (jsonrpsee’s own sink: stdio, an in-memory module)the item’s bytes go to the sink as one raw value, as before
one change fans out to N watchers (Shared)the first socket that sends it encodes it, once; every other writes those bytes
a call has an input half (super::input)[pipe_duplex] takes it instead: the same frames and buffer, and beside the method’s items the frames of the input half (credit, ack, input_closed), made here since they are this transport’s and no method’s. pipe is unchanged by them
the client offered batch at its upgrade (FrameSink::batching, PERF-8)the items a stream has ready together, up to the batch and about BATCH_BYTES, go in one notification whose results are their array, the metadata said once; a lone item goes at once, in today’s form

PERF-8 batches frames here (results: […]), PERF-9 adds an encoding (WireEncoding), PERF-13 relays a child’s content as bytes.

Structs§

Content
A data item’s content: the method’s event, encoded once (JSON bytes), or a Value — whichever the item was made with. Reads as a Value either way (Content::value, Deref), the bytes decoded once on demand; serializes as its JSON. Equal as JSON is equal.
FrameSink
The frames a transport takes from a connection’s calls (plexus-transport’s socket loop puts one in each call’s extensions): each item a frame, in order, written as it is. Cheap to clone.
Shared
An event many streams send — one change fanned out to every watcher. The first socket that sends it encodes it, once; every other writes those bytes as they are (PERF-7’s fan-out). Anywhere else (in process, a Value, another encoding) it serializes as T does. Reads as T.
WireFrame
A frame ready for a socket, in its connection’s encoding.

Enums§

WireEncoding
The encoding of every frame on a connection, fixed when it opens. JSON text until PERF-9 adds msgpack.

Constants§

BATCH_BYTES
Where a batch stops taking items: once what it holds reaches this many bytes, so a batch of large items stays small. A queue’s 1,024 frames are bounded by frames, not bytes (PERF.115-37), and each item takes its size twice from a block: 64 items of 4 KB to a frame held 280 KB a frame and allocated a 512 KiB block every few frames, 16 KiB still 4,096 B an item in one run of two, and a ticket body’s batch would hold a megabyte. At 8 KiB a full queue of 4 KB items holds about 18 MB, which the call’s 80 spare blocks keep. PERF-17 found a count alone cost a 4 KB stream 27 %, and said a batch should stop at bytes.
MAX_BATCH
The most items one notification carries when the client offered batch at its upgrade (PERF-8, spec/02): a client may ask for fewer.

Functions§

pipe
Pipe a call’s stream to its accepted subscription: each item encoded once and written as one frame.

Type Aliases§

FrameReceiver
What the transport’s writer reads a FrameSink’s frames from.