Skip to content

[Backend] Add memory profiling and leak detection benchmarks - #746

Merged
EDOHWARES merged 1 commit into
SoroLabs:mainfrom
blessedDev-xyz:feature/586-bench-memory
Aug 1, 2026
Merged

[Backend] Add memory profiling and leak detection benchmarks#746
EDOHWARES merged 1 commit into
SoroLabs:mainfrom
blessedDev-xyz:feature/586-bench-memory

Conversation

@blessedDev-xyz

Copy link
Copy Markdown

Summary

Add core/benches/memory_bench.rs — Criterion benchmarks that use tikv-jemallocator as the global allocator and tikv-jemalloc-ctl to query heap statistics, enabling detection of allocation churn and RSS memory growth in long-running indexer processes.

Changes

  • core/benches/memory_bench.rs (new):

    • memory/merkle_build: heap delta per build+drop iteration (1K / 10K / 100K leaves)
    • memory/allocation_churn: net retained bytes after 100 repeated build+drop cycles — non-zero growth indicates a leak
    • memory/proof_generation: residual heap after exhaustive proof generation across all leaves
    • memory/idle_allocated_bytes: steady-state RSS snapshot for CI baseline comparison
    • Uses tikv_jemallocator::Jemalloc as #[global_allocator] and tikv_jemalloc_ctl::epoch + stats::allocated for precise heap reads
  • core/Cargo.toml:

    • Added criterion = "0.5", tikv-jemalloc-ctl = "0.5", tikv-jemallocator = "0.5" to dev-dependencies
    • Added [[bench]] declarations for memory_bench and merkle_bench (previously missing harness flag)

Usage

cargo bench --bench memory_bench
# Results in target/criterion/memory/

Validation

  • cargo check --benches passes with no errors

Closes #586

Add core/benches/memory_bench.rs using tikv-jemallocator as global
allocator and tikv-jemalloc-ctl to query heap stats, monitoring for
allocation churn and RSS growth in long-running indexer processes.

Benchmarks:
- memory/merkle_build: heap delta per build+drop iteration across 1K/10K/100K leaves
- memory/allocation_churn: net retained bytes after 100 repeated build cycles
- memory/proof_generation: residual heap after exhaustive proof generation
- memory/idle_allocated_bytes: steady-state RSS baseline for CI comparison

Add criterion + tikv-jemalloc* dev-dependencies and [[bench]] manifests
for both memory_bench and the existing merkle_bench (previously missing
harness declaration).

Closes SoroLabs#586
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@blessedDev-xyz Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@EDOHWARES

Copy link
Copy Markdown
Collaborator

Nice implementation, LGTM!

@EDOHWARES
EDOHWARES merged commit 50b44d7 into SoroLabs:main Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Backend] Add Memory Profiling and Leak Detection Benchmarks

3 participants