Index · How it works
1 min readRapid overview
How it works
8️⃣ Interview-ready example (say this at)
“Allocation discipline means being intentional about where and how you allocate. In latency-sensitive systems, even Gen0 collections matter. I use
ArrayPool<T>andObjectPool<T>to reuse memory,Span<T>for parsing binary and textual data, and avoid LINQ or string concatenation in tight loops. I measure Allocated Bytes/sec and Gen0 frequency in production to ensure the system stays allocation-stable. Our goal isn’t zero GC — it’s predictable, bounded GC behavior.”
9️⃣ Trading-system tie-in (concrete example)
Without discipline:
foreach (var msg in feed)
{
var parts = msg.Split(',');
var tick = new Tick(parts[0], double.Parse(parts[1]), double.Parse(parts[2]));
Publish(tick);
}
→ Creates new string arrays, substrings, doubles → Gen0/Gen1 churn.
With discipline:
byte[] buffer = ArrayPool<byte>.Shared.Rent(1024);
ReadOnlySpan<byte> span = buffer.AsSpan(0, bytesRead);
ParseTick(span);
ArrayPool<byte>.Shared.Return(buffer);
→ Zero heap allocations, predictable performance, stable GC profile.