Context
compare_ffi_memory.rs reports total bytes allocated by Rust vs FFI per scenario but doesn't attribute allocations to call sites.
Resolution
Implemented as the dhat-heap cargo feature (default off) wired into the standalone profiling examples instead of the criterion harness:
zstd/Cargo.toml: optional dhat = "0.3" dep behind dhat-heap feature
zstd/examples/encode_loop_reuse_z000033.rs, zstd/examples/encode_loop_dict.rs: global allocator + profiler blocks; write dhat-heap.json with per-call-site blocks/bytes (totals, t-gmax, t-end)
The standalone-example shape beats the original compare_ffi_memory.rs plan: the criterion harness pollutes attribution with setup/training/validation allocations, while the examples isolate the steady-state loop. Allocation COUNTS are platform-independent, so runs on any host diagnose musl-amplified churn.
Proven in practice: attributed the 13 allocs/frame on the reused-compressor dict path (row-table oscillation / estimator boxes / huffman seed clone / header temporaries) and the BT dms per-frame rebuild — both eliminated (musl 5.5× win).
The donor-proxy delta column (vs ZSTD_sizeof_CCtx) was not built; compare_ffi_memory.rs totals already give the cross-side comparison, dhat gives the our-side breakdown.
Context
compare_ffi_memory.rsreports total bytes allocated by Rust vs FFI per scenario but doesn't attribute allocations to call sites.Resolution
Implemented as the
dhat-heapcargo feature (default off) wired into the standalone profiling examples instead of the criterion harness:zstd/Cargo.toml: optionaldhat = "0.3"dep behinddhat-heapfeaturezstd/examples/encode_loop_reuse_z000033.rs,zstd/examples/encode_loop_dict.rs: global allocator + profiler blocks; writedhat-heap.jsonwith per-call-site blocks/bytes (totals, t-gmax, t-end)The standalone-example shape beats the original compare_ffi_memory.rs plan: the criterion harness pollutes attribution with setup/training/validation allocations, while the examples isolate the steady-state loop. Allocation COUNTS are platform-independent, so runs on any host diagnose musl-amplified churn.
Proven in practice: attributed the 13 allocs/frame on the reused-compressor dict path (row-table oscillation / estimator boxes / huffman seed clone / header temporaries) and the BT dms per-frame rebuild — both eliminated (musl 5.5× win).
The donor-proxy delta column (vs
ZSTD_sizeof_CCtx) was not built;compare_ffi_memory.rstotals already give the cross-side comparison, dhat gives the our-side breakdown.