Memory & Storage Benchmarks

Read time 4 minutes
On this page

Nalix uses a highly optimized memory management subsystem designed to eliminate Garbage Collection (GC) pauses in high-throughput workloads.

Buffer Pooling & Leases

Comparison of memory acquisition strategies across various sizes (64 B, 1 KB, and 16 KB).

Buffer Allocation Metrics (Size = 64)

MethodMeanErrorStdDevP95RatioAllocatedAlloc Ratio
RawAllocation16.974 ns1.3931 ns1.6043 ns19.503 ns1.0188 B1.00
ArrayPool_Shared10.824 ns0.3976 ns0.4579 ns11.244 ns0.640 B0.00
BufferPoolManager_RentReturn23.905 ns0.6627 ns0.7632 ns24.545 ns1.420 B0.00
BufferLease_RentDispose54.052 ns0.5018 ns0.5778 ns54.617 ns3.210 B0.00

Buffer Allocation Metrics (Size = 1024)

MethodMeanErrorStdDevP95RatioAllocatedAlloc Ratio
RawAllocation159.487 ns29.9061 ns34.4399 ns194.306 ns1.061048 B1.00
ArrayPool_Shared6.406 ns0.0902 ns0.1039 ns6.556 ns0.040 B0.00
BufferPoolManager_RentReturn24.173 ns0.4341 ns0.4999 ns24.471 ns0.160 B0.00
BufferLease_RentDispose62.729 ns1.1419 ns1.3150 ns63.688 ns0.420 B0.00

Buffer Allocation Metrics (Size = 16384)

MethodMeanErrorStdDevP95RatioAllocatedAlloc Ratio
RawAllocation2,608.051 ns452.9858 ns521.6591 ns3,035.733 ns1.06216408 B1.00
ArrayPool_Shared10.496 ns0.8494 ns0.9782 ns11.159 ns0.0040 B0.00
BufferPoolManager_RentReturn23.769 ns0.6516 ns0.7504 ns24.451 ns0.0100 B0.00
BufferLease_RentDispose53.938 ns1.3191 ns1.5190 ns54.873 ns0.0220 B0.00

Why Nalix Memory?

  • Pooled Array Rental (BufferPoolManager): BufferPoolManager wraps ArrayPool<byte>.Shared with atomic rent/return counters and optional leak-detection diagnostics (BufferOptions.EnableBufferLeakDetection), delivering 0 B allocation across all payload sizes.
  • Reference-Counted Lease Safety (BufferLease): BufferLease provides a pooled, reference-counted (Retain() / Dispose()) rental wrapper (IBufferLease) that keeps rent/dispose cycles allocation-free (0 B) while preventing premature buffer returns across async boundaries.

Object Pooling

Memory metrics for reusing class instances via object pools.

MethodMeanErrorStdDevP95RatioAllocatedAlloc Ratio
RawAllocation8.016 ns0.4384 ns0.5049 ns8.474 ns1.0032 B1.00
RentAndReturn_ObjectPool157.624 ns5.2398 ns6.0342 ns161.363 ns19.740 B0.00

Behind the design

  • Object Reusability: Reusing instances of complex structures (like session states, packet envelopes, and processing contexts) prevents Gen 0 GC thrashing.
  • Hybrid Fast-Path Architecture:
    • Thread-Local Cache: First-level lock-free lookup caches object instances in thread-local storage (ThreadLocalCache<T>) for ultra-low latency reuse on the same thread.
    • Type-Indexed Buckets: When thread-local slots are empty or full, retrieval falls back to an array-backed lookup using compiled type IDs (PoolType<T>.Id) to bypass slow hashing or generic dictionary lookups.
  • Reset Logic: To prevent state pollution across rentals, pooled objects implement a reset interface (IPoolable) that automatically wipes data and prepares the instance for reuse upon its return to the pool.