Transparent Hugepage Compaction Shock Slippage Playbook

2026-03-17 · finance

Transparent Hugepage Compaction Shock Slippage Playbook

Why this exists

Execution stacks can look perfectly healthy at CPU%, NIC, and app-level p50 latency, while still leaking tail slippage.

One overlooked source: Linux THP compaction behavior (direct reclaim/compaction on allocation paths, plus background khugepaged collapse pressure) creating short scheduler stalls and bursty dispatch cadence.

Those micro-stalls can desynchronize child-order timing and queue priority, especially in thin/fast books.


Core failure mode

When memory is fragmented and THP policy is too aggressive for low-latency workloads:

Result: tail implementation shortfall rises without obvious infra alarms.


Slippage decomposition with memory-compaction terms

For parent order (i):

[ IS_i = C_{delay} + C_{impact} + C_{miss} + C_{compaction-shock} ]

Where:

[ C_{compaction-shock} = C_{stall} + C_{burst-bunch} + C_{queue-reset} ]


Feature set (production-ready)

1) Kernel/MM pressure features

2) Runtime stall features

3) Dispatch microstructure features

4) Outcome features


Model architecture

Use a baseline + overlay structure.

  1. Baseline slippage model
    • existing desk model (impact/fill/toxicity/deadline)
  2. Compaction-shock overlay
    • predicts incremental uplift during MM stress windows:
      • delta_is_mean
      • delta_is_q95

Final estimate:

[ \hat{IS}{final} = \hat{IS}{baseline} + \Delta\hat{IS}_{mm-shock} ]

Train overlay with episode labeling around compaction-stall bursts and matched non-burst controls (same symbol/session regime) to separate MM effects from market volatility.


Regime controller

State A: MM_CLEAN

State B: MM_WATCH

State C: MM_SHOCK

State D: SAFE_MM_INTEGRITY

Use hysteresis + minimum dwell times to avoid control flapping.


Desk metrics

Track by host + strategy + symbol-liquidity bucket.


Practical mitigation ladder

  1. Observe first
    • instrument vmstat + dispatch gaps + slippage branch labels
  2. Policy hardening
    • prefer madvise over global always for THP in latency-critical services
    • avoid aggressive defrag in critical execution paths
  3. Memory layout discipline
    • isolate latency-critical processes from heavy memory churn workloads
    • pin/control background tasks that trigger compaction pressure
  4. Execution fallback rails
    • when MM_SHOCK, cap child-size jumps and replace frequency
    • throttle panic catch-up to prevent queue-reset cascades

Failure drills (must run)

  1. Synthetic memory-fragmentation drill
    • verify MM_WATCH triggers before tail slippage explosion
  2. Compaction-burst replay drill
    • confirm overlay uplift captures q95 deterioration
  3. Fallback-policy drill
    • ensure SAFE_MM_INTEGRITY action path is one-command reversible
  4. Confounder drill
    • separate MM shock from GC/NIC spikes in incident tagging

Anti-patterns


Bottom line

THP can improve throughput/TLB behavior, but in execution systems the wrong compaction profile can quietly inject latency bursts that your router converts into queue-priority loss and tail-cost blowups.

Model memory-compaction shock as a first-class slippage component, and wire explicit regime controls before infra jitter becomes basis-point leakage.