A reproducible RAM‑regression workflow in Rust with dhat + heaptrack
Description and use
An automated recipe for memory regression detection in Rust media projects using dhat for test‑time heap budgeting and heaptrack in CI to capture allocation call stacks.
Problem
Media pipelines often suffer from subtle RAM regressions that are hard to detect with standard perf counters.
Outcome
Tests now fail immediately when memory usage exceeds the set budget, and CI provides detailed allocation call stacks to pinpoint regressions.
Workflow
- Pin Rust toolchain and lockfile
- Set RUSTFLAGS to a fixed target CPU
- Use DhatAlloc only in tests, System allocator in CI
- Run deterministic media workload with fixed thread count
- Assert HeapStats.max_bytes <= budget in test
- Run heaptrack in CI to capture call stacks
- Diff heaptrack artifacts against baseline
- Automate baseline updates and bisect on regressions
Evidence
Use dhat in tests to enforce peak‑heap budgets and fail fast on regressions.
Use heaptrack in CI to capture call stacks and quantify where new allocations appear.
- Record date: 2026-09-15T10:15:32.834Z