Module Algostream_common_utils.Zero_copy

Zero-copy message passing for ultra-low latency trading

exception Invalid_message_size of int
exception Buffer_overflow
exception Channel_closed
exception Invalid_channel_id of int
type message_header = {
  1. magic : int32;
  2. message_type : int32;
  3. sequence_id : int64;
  4. timestamp_ns : int64;
  5. payload_size : int32;
  6. checksum : int32;
}

Message header for zero-copy transport

val message_header_size : int
val magic_number : int32
type zero_copy_channel

Zero-copy channel for bidirectional communication

module MessageType : sig ... end

Message type definitions

val create_channel : channel_id:int -> capacity:int -> message_size:int -> zero_copy_channel

Create a zero-copy channel

val connect_channel : channel_id:int -> capacity:int -> message_size:int -> zero_copy_channel

Connect to an existing zero-copy channel

val close_channel : zero_copy_channel -> unit

Close a zero-copy channel

val send_message : zero_copy_channel -> int32 -> bytes -> unit

Send a message through the channel

val receive_message : zero_copy_channel -> (message_header * bytes) option

Receive a message from the channel

val try_receive_message : zero_copy_channel -> (message_header * bytes) option

Try to receive a message without blocking

module MarketDataZeroCopy : sig ... end

Specialized zero-copy structures for market data

type channel_stats = {
  1. messages_sent : int64;
  2. messages_received : int64;
  3. bytes_sent : int64;
  4. bytes_received : int64;
  5. avg_send_latency_ns : int64;
  6. avg_receive_latency_ns : int64;
  7. checksum_failures : int64;
  8. buffer_overflows : int64;
}

Channel statistics

module ZeroCopyMetrics : sig ... end

Performance monitoring for zero-copy channels

module ChannelManager : sig ... end

Channel manager for handling multiple zero-copy channels