Skip to main content
Tango is Firedancer’s zero-copy, lock-free IPC framework designed for ultra-low-latency message passing between processing units. It provides the foundational messaging primitives used throughout Firedancer for communication between tiles, processes, and system components.

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)
Fragment metadata:

Control Bits

Fragment boundaries:
  • SOM (Start-of-Message): First fragment of a message
  • EOM (End-of-Message): Last fragment of a message
  • ERR (Error): Entire message is corrupt (discard)
Origin tracking:
  • 13-bit origin ID (0-8191)
  • Identifies message producer
  • Up to FD_FRAG_META_ORIG_MAX (8192) origins

Sequence Numbers

Properties:
Sequence number math:

Architecture Components

Mcache (mcache/)

Hybrid ring buffer + direct-mapped cache for fragment metadata:Structure:
  • Ring buffer of fd_frag_meta_t entries
  • Power-of-2 size (typically 4K-1M entries)
  • Direct mapping: seq % depth → cache line
  • Lock-free atomic updates (SSE/AVX instructions)
Access patterns:
Depth sizing:
  • Small queues: 1K-4K entries (low latency)
  • Deep queues: 256K-1M entries (burst absorption)
  • Trade-off: Memory vs. overrun tolerance
Memory footprint:
  • Each entry: 32 bytes (FD_FRAG_META_SZ)
  • Aligned to 32 bytes (FD_FRAG_META_ALIGN)
  • Total: depth * 32 bytes

Dcache (dcache/)

Payload storage with chunk-granular allocation:Chunk system:
Chunk addressing:
Properties:
  • 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
Allocation strategies:
  • Linear allocation (sequential writes)
  • Circular buffer (fixed-size messages)
  • Custom allocators (variable-size)

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
Credit types:
  • Fragment credits: Number of fragments consumer can receive
  • Chunk credits: Amount of dcache space available
Usage:

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
Memory layout:
Operations:

Tcache (tcache/)

Specialized cache for transaction metadata:Features:
  • Transaction-specific metadata storage
  • Deduplication support
  • Tag-based lookup
  • Recent transaction tracking
Use case:
  • Disco dedup tile uses tcache
  • Maps transaction signature → metadata
  • Fast duplicate detection

CNC (cnc/)

Tile lifecycle and health management:Functions:
  • Tile start/stop signaling
  • Heartbeat monitoring
  • State machine coordination
  • Diagnostic queries
State transitions:
Heartbeat:
  • Periodic “I’m alive” signal
  • Timeout detection
  • Automatic restart on failure

Tempo (tempo/)

Wallclock and timing utilities:Features:
  • Synchronized wallclock access
  • Timestamp compression/decompression
  • Temporal comparisons
  • Nanosecond precision
Timestamp compression:
Accuracy:
  • ±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

Reassembly logic:
  1. Wait for SOM fragment from origin
  2. Accumulate fragments until EOM
  3. Check for sequence number gaps (overrun)
  4. 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):
Benefits:
  • Huge page backed (2MB/1GB pages)
  • NUMA-aware allocation
  • Persistent across processes
  • Named objects for discovery
  • Standard UNIX permissions

Control Utility

Tango provides fd_tango_ctl for management and inspection:

Header Files

  • Disco - Uses Tango for tile communication
  • Util - Workspace management (wksp)