Monotonic Peak Profiles (MPPs)
- MPPs is a non-parametric denoising transform that converts noisy memory-usage traces into non-decreasing profiles by capturing cumulative memory peaks.
- It enables accurate, shape-based comparison of memory growth across executions, effectively suppressing transient fluctuations and noise.
- MPPs serve as the foundation for the Dynamic Mean Pairwise Distance metric, quantifying runtime memory divergence across diverse software implementations.
Monotonic Peak Profiles (MPPs) are a non-parametric denoising transform for memory-usage time series, introduced to provide a rigorous algorithmic summary of peak-memory behavior in software executions. By converting memory-usage traces into a non-decreasing profile that traces only the cumulative maxima—thus suppressing all downward fluctuations—MPPs enable robust, shape-based comparison of algorithmic memory growth across multiple code executions, especially under non-deterministic or noisy runtime conditions. This construct is foundational to the Dynamic Mean Pairwise Distance (DMPD) metric for quantifying runtime memory divergence among semantically equivalent but implementation-diverse solutions, as proposed in "Correctness isn’t Efficiency: Runtime Memory Divergence in LLM-Generated Code" (Rajput et al., 3 Jan 2026).
1. Formal Definition and Construction
Let denote the raw memory-usage sample at discrete step , , as measured by profilers such as tracemalloc. The Monotonic Peak Profile (MPP) is constructed in two principal stages: baseline correction and cumulative maximum.
- Baseline Correction: The sequence is offset such that the first memory sample becomes zero:
- Cumulative Maximum: The monotonic profile is then defined as the sequence of cumulative maxima of :
By this construction, is guaranteed to be non-decreasing, thereby highlighting each new maximal allocation event and ignoring subsequent decreases—regardless of their duration or amplitude.
2. Algorithmic Procedure and Parameterization
The canonical algorithm for deriving MPPs from raw traces admits optional quantization and subsampling procedures. The procedure is as follows:
- Inputs: Raw trace ; quantization bucket (default $64$ B); sampling stride (default $1$).
- Subsampling (optional): For line-based or time-based downsampling, define .
- Baseline Correction: , floored to $0$ if negative.
- Quantization (optional): Round to the nearest bucket: .
- Cumulative Maximum: ; for , .
- Output: The sequence .
No explicit sliding window, thresholding, or parametric smoothing is involved; monotonicity is enforced purely via the cumulative-max operation.
3. Illustrative Example and Tabulation
Given a sample memory trace:
| 1 | 100 | 0 | 0 |
| 2 | 150 | 50 | 50 |
| 3 | 130 | 30 | 50 |
| 4 | 180 | 80 | 80 |
| 5 | 160 | 60 | 80 |
| 6 | 200 | 100 | 100 |
Plotting the raw produces pronounced up–and–down jitter; yields the non-decreasing "upper envelope" that tracks novel allocations (e.g., data structure growth) while eliminating transient frees or allocator noise.
4. Noise Suppression and Memory-Usage Semantics
Real-world execution traces typically reflect not only algorithmic memory allocations but also environmental artifacts such as temporary buffers, garbage-collection activities, and allocator fragmentation. MPP eliminates all post-peak dips by construction: once a new high-water mark is observed, all future values remain at or above this level. This selective retention of peaks ensures that the resulting profile captures allocations of lasting algorithmic significance while disregarding transient runtime churn. Empirical results demonstrate that MPP-aligned traces from independent executions exhibit systematically lower variance in pairwise metrics than do raw or even conventionally smoothed traces (Rajput et al., 3 Jan 2026).
5. Integration with Dynamic Mean Pairwise Distance (DMPD)
MPPs constitute the input sequences for the DMPD framework, which quantifies pairwise divergence between two program executions. The process comprises:
- Unit-Peak Normalization: For each MPP , , compute , .
- Shape Alignment via Dynamic Time Warping (DTW): Construct cost matrix with local cost and recurrence:
with , .
- DMPD Computation: The average-cost per warping step of the optimal DTW path, yielding
where is the path realizing the minimum cumulative cost.
Thus, MPP enables a scale-robust, shape-sensitive, and noise-invariant basis for automated profiling of algorithmic memory dynamics across diverse implementations.
6. Parameters, Defaults, and Interpretation
Key parameters influencing MPP computation include:
| Parameter | Purpose | Default |
|---|---|---|
| Quantization bucket | Rounds allocations to -byte multiples to suppress low-level allocator noise | $64$ B |
| Sampling stride | Controls subsampling rate; smaller yields finer resolution | $1$ |
| Minimum peak | Discards trivial profiles with final peak below threshold | (not specified) |
No peak threshold or sliding window is required; monotonicity alone determines the MPP. Overly sparse sampling can miss narrow or short-lived allocation spikes, while coarse quantization suppresses fine-grained events.
7. Limitations and Domain Considerations
While MPPs confer robustness to noisy runtime behavior, several limitations are intrinsic:
- All downward dips—including semantically meaningful frees—are suppressed, precluding discrimination between allocate–free–allocate cycles and monotonic growth.
- In runtimes with complex GC behavior or bulk/batched allocation commits, observed peaks may not correspond directly to algorithmic events, but rather reflect allocator-internal actions.
- Cases involving permanent deallocation and memory reuse are not interpretable via MPP, which may overstate memory footprint by ignoring true reuse.
- Sufficient sampling density is essential to capture brief peaks; otherwise, peak events may be missed.
- MPP profiles are runtime-dependent; results in (Rajput et al., 3 Jan 2026) are based on CPython/tracemalloc, and runtime differences (JVM, Go, Rust) affect trace character.
Despite these caveats, MPP serves as a robust, implementation-agnostic summary of memory usage for comparative stability analysis, supporting the reduction of operational risk in the selection of correct program candidates without requiring explicit semantic annotation or invasive runtime modification (Rajput et al., 3 Jan 2026).