Overview
Tango implements a sophisticated messaging system based on fragments (variable-size message chunks) with metadata-driven routing and filtering. The design enables:- Zero-copy communication: Direct memory access without data copying
- Lock-free operations: No mutex contention in critical paths
- Ordered delivery: Strict sequential ordering with gap detection
- Overrun detection: Automatic detection of lost messages
- Multi-producer/multi-consumer: Flexible topology support
Tango’s design allows seamless transition between single-process threaded and multi-process distributed deployments without code changes.
Core Concepts
Message Fragments
Messages in Tango are partitioned into fragments:- Each fragment carries 0-65,535 bytes of payload
- Fragments have 64-bit globally unique sequence numbers
- Multi-fragment messages are supported (unlimited fragments per message)
- Zero-sized fragments are valid (heartbeat/keepalive)
Control Bits
Fragment boundaries:SOM(Start-of-Message): First fragment of a messageEOM(End-of-Message): Last fragment of a messageERR(Error): Entire message is corrupt (discard)
- 13-bit origin ID (0-8191)
- Identifies message producer
- Up to
FD_FRAG_META_ORIG_MAX(8192) origins
Sequence Numbers
Properties:Architecture Components
Fragment Metadata Cache (mcache)
Fragment Metadata Cache (mcache)
Mcache (mcache/)
Hybrid ring buffer + direct-mapped cache for fragment metadata:Structure:- Ring buffer of
fd_frag_meta_tentries - Power-of-2 size (typically 4K-1M entries)
- Direct mapping:
seq % depth→ cache line - Lock-free atomic updates (SSE/AVX instructions)
- Small queues: 1K-4K entries (low latency)
- Deep queues: 256K-1M entries (burst absorption)
- Trade-off: Memory vs. overrun tolerance
- Each entry: 32 bytes (
FD_FRAG_META_SZ) - Aligned to 32 bytes (
FD_FRAG_META_ALIGN) - Total:
depth * 32bytes
Data Cache (dcache)
Data Cache (dcache)
Dcache (dcache/)
Payload storage with chunk-granular allocation:Chunk system:- 32-bit chunk IDs (4 billion chunks max)
- Chunk 0 is base address
- All chunks 64-byte aligned
- Max data region: 256 GB per dcache
- Linear allocation (sequential writes)
- Circular buffer (fixed-size messages)
- Custom allocators (variable-size)
Flow Control (fctl)
Flow Control (fctl)
Fctl (fctl/)
Credit-based flow control for backpressure:Mechanism:- Consumer publishes credits (“I can receive N fragments”)
- Producer consumes credits before sending
- Prevents overrun of slow consumers
- Dynamic credit replenishment
- Fragment credits: Number of fragments consumer can receive
- Chunk credits: Amount of dcache space available
Sequence Tracker (fseq)
Sequence Tracker (fseq)
Fseq (fseq/)
Shared sequence number for synchronization:Purpose:- Publisher advertises latest sequence number
- Multiple consumers read the same fseq
- Enables “pub-sub” patterns
- Flow control signal publishing
Transaction Cache (tcache)
Transaction Cache (tcache)
Tcache (tcache/)
Specialized cache for transaction metadata:Features:- Transaction-specific metadata storage
- Deduplication support
- Tag-based lookup
- Recent transaction tracking
- Disco dedup tile uses tcache
- Maps transaction signature → metadata
- Fast duplicate detection
Command & Control (CNC)
Command & Control (CNC)
CNC (cnc/)
Tile lifecycle and health management:Functions:- Tile start/stop signaling
- Heartbeat monitoring
- State machine coordination
- Diagnostic queries
- Periodic “I’m alive” signal
- Timeout detection
- Automatic restart on failure
Timing (tempo)
Timing (tempo)
Tempo (tempo/)
Wallclock and timing utilities:Features:- Synchronized wallclock access
- Timestamp compression/decompression
- Temporal comparisons
- Nanosecond precision
- ±2.1 seconds from reference
- Suitable for latency measurements
- No clock synchronization required
Message Reassembly
Single-Fragment Messages
Simplest case (most common):Multi-Fragment Messages
- Wait for SOM fragment from origin
- Accumulate fragments until EOM
- Check for sequence number gaps (overrun)
- If ERR bit set, discard entire message
Signature Filtering
Consumers can filter messages without reading payloads:Performance Characteristics
Atomic Operations
Tango uses x86 atomic instructions for lock-free updates:Memory Ordering
Benchmarks (typical)
- Latency: 20-50 ns (mcache read)
- Throughput: 100M+ fragments/sec (single producer)
- Scalability: Linear with # of producers
- Overrun detection: Zero overhead
Constants & Limits
Usage Example
Workspace Integration
Tango objects live in Firedancer workspaces (wksp):
- Huge page backed (2MB/1GB pages)
- NUMA-aware allocation
- Persistent across processes
- Named objects for discovery
- Standard UNIX permissions
Control Utility
Tango providesfd_tango_ctl for management and inspection: