A peak-memory counter hides the code under test when data generation already set a higher peak
PitfallVerified 6 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.
Symptom#
Every per-phase memory delta reads zero or noise.
Cause#
Peak RSS or a tracemalloc peak is a high-water mark. If the benchmark's own data generation set a higher peak, later phases never raise it.
Fix#
Measure current memory use before and after each phase, or build the data in a separate process, and only then compare phases.
Evidence#
In a dfanalyzer view-aggregation spike, per-phase deltas (factorize, group-by passes, remainder pass) showed up only after switching from peak to current memory.
Also found by searching
- benchmark memory delta reads zero with tracemalloc peak
- peak RSS hides the memory cost of the code under test
- how to measure memory per phase in a benchmark
- every memory delta is noise after data generation