Skip to main content

Module ipc

Module ipc 

Source
Expand description

IPC Protocol with Multiplexing and Streaming

From mm.md Task 7.1: Pipelined IPC Protocol

§Problem

Current IPC is request-response, blocking client during server work:

Client: Send Request -> Wait -> Receive Response -> Send Next Request
Latency: sum of all request latencies

§Solution

Pipelining with request IDs and async responses:

+------------+     +------------+
|   Client   |     |   Server   |
+------------+     +------------+
      |                   |
      |--- Req(id=1) ---->|
      |--- Req(id=2) ---->|
      |--- Req(id=3) ---->|  (no wait)
      |                   |
      |<-- Resp(id=2) ----|  (out-of-order OK)
      |<-- Resp(id=1) ----|
      |<-- Resp(id=3) ----|
      |                   |

Protocol: Unix domain socket with length-prefixed messages
Frame: [4-byte length][request_id: u64][msg_type: u8][payload...]

§Benefits

  • No head-of-line blocking
  • Batched network I/O
  • Supports streaming responses for large result sets
  • Backpressure through flow control

Structs§

BatchRequest
Batch request builder for efficient pipelining
FlowControl
Flow control state
Frame
Complete IPC frame
FrameHeader
IPC frame header
FrameReader
Frame reader for parsing incoming frames
FrameWriter
Frame writer for serializing outgoing frames
IpcServer
IPC server for handling incoming connections
RequestMultiplexer
Request multiplexer for pipelining
StreamWriter
Stream response writer for sending chunked results

Enums§

IpcError
IPC error types
MessageType
Message types in the IPC protocol

Traits§

RequestHandler
Request handler trait for server-side processing

Type Aliases§

RequestId
Request ID for tracking pipelined requests
StreamId
Stream ID for multiplexed streams