A reproducible RAM‑regression workflow in Rust with dhat + heaptrack
Описание и применение
Автоматизированный рецепт проверки памяти в Rust‑медиа‑проекте с использованием dhat для тестов и heaptrack в CI, позволяющий быстро обнаруживать и локализовать регрессии памяти.
Задача
Media pipelines often suffer from subtle RAM regressions that are hard to detect with standard perf counters.
Результат
Tests now fail immediately when memory usage exceeds the set budget, and CI provides detailed allocation call stacks to pinpoint regressions.
Рабочий процесс
- 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
Доказательства
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.
- Дата записи: 2026-09-15T10:15:32.834Z