Performance Engineering

Real-time p50/p95/p99 latency, GC behavior, allocation rate, and throughput metrics — updated every second

Why These Metrics Matter in Trading

In high-frequency trading systems, tail latency kills. A system that averages 50μs but occasionally spikes to 50ms will miss fill opportunities. The metrics below are what SIG/Optiver/Jane Street infrastructure teams monitor in production:

  • p50 (median): Typical processing time — your baseline experience
  • p95: The "busy period" latency — what happens during market opens
  • p99: The real danger zone — if this is high, you're dropping messages
  • GC pauses: .NET's garbage collector can introduce unpredictable stalls. Server GC + low-allocation patterns minimize this.
  • Allocation rate: High allocation rate → frequent GC → latency spikes. ArrayPool and Span<T> are the cure.

Latency Percentiles (Live)

p50
p95
p99
peak

Throughput

MESSAGES/SEC
0
TOTAL PROCESSED
0
TOTAL BYTES
0
processed
UPTIME
0s

Garbage Collection

Monitoring GC behavior is critical. Gen0 collections are cheap but frequent. Gen2 collections cause full STW (stop-the-world) pauses. This system uses ArrayPool<T> for percentile buffers and pre-allocated batch lists to minimize Gen0 pressure.

GEN 0
0
+0 since last
GEN 1
0
+0 since last
GEN 2
0
+0 since last
HEAP SIZE
0
MB
GC PAUSE TIME
0
ms total
LATENCY MODE
SERVER GC

Allocation Rate

Bytes allocated since last snapshot. Lower is better — high allocation pressure triggers more frequent GC collections.

0 KB 0 KB/sec 10 MB

Optimization Techniques Used

TECHNIQUELOCATIONIMPACT
ArrayPool<long>.Shared.Rent() PerformanceMetrics.GetSnapshot() Zero-allocation percentile computation
Pre-allocated List<T>(50) TradeQueueProcessor batch buffer No resize allocations on hot path
Interlocked operations All counters and stats Lock-free; no mutex contention
Circular buffer (power-of-2) Latency sample storage (4096) Bitwise AND instead of modulo; cache-friendly
Stopwatch.GetTimestamp() Latency measurement High-resolution; no DateTime allocation
Bounded DOM (60 rows) Frontend signal feed Prevents DOM explosion under high msg rates