Skip to content

feat: memory profiling script#587

Draft
ly0va wants to merge 1 commit into
devfrom
lyova/memory-profiling
Draft

feat: memory profiling script#587
ly0va wants to merge 1 commit into
devfrom
lyova/memory-profiling

Conversation

@ly0va
Copy link
Copy Markdown
Member

@ly0va ly0va commented Mar 23, 2026

What ❔

A script to profile e2e test peak memory usage

Why ❔

Airbender v2 uses considerably more memory

Is this a breaking change?

  • Yes
  • No

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • Code has been formatted.

@github-actions
Copy link
Copy Markdown
Contributor

Benchmark report

Benchmark Symbol Base Eff Head Eff (%) Base Raw Head Raw (%) Base Blake Head Blake (%) Base Bigint Head Bigint (%)
block_19299001 process_block 315,688,611 315,688,611 (+0.00%) 273,023,211 273,023,211 (+0.00%) 410,630 410,630 (+0.00%) 9,023,830 9,023,830 (+0.00%)
block_22244135 process_block 197,589,754 197,589,754 (+0.00%) 170,673,962 170,673,962 (+0.00%) 172,040 172,040 (+0.00%) 6,040,788 6,040,788 (+0.00%)
precompiles bn254_ecadd 53,268 53,268 (+0.00%) 47,816 47,816 (+0.00%) 0 0 (+0.00%) 1,363 1,363 (+0.00%)
precompiles bn254_ecmul 728,781 728,781 (+0.00%) 564,593 564,593 (+0.00%) 0 0 (+0.00%) 41,047 41,047 (+0.00%)
precompiles bn254_pairing 72,336,733 72,336,733 (+0.00%) 57,808,589 57,808,589 (+0.00%) 0 0 (+0.00%) 3,632,036 3,632,036 (+0.00%)
precompiles ecrecover 479,217 477,095 (-0.44%) 310,669 309,111 (-0.50%) 0 0 (+0.00%) 42,137 41,996 (-0.33%)
precompiles id 927 927 (+0.00%) 927 927 (+0.00%) 0 0 (+0.00%) 0 0 (+0.00%)
precompiles keccak 137,579 137,579 (+0.00%) 137,579 137,579 (+0.00%) 0 0 (+0.00%) 0 0 (+0.00%)
precompiles modexp 31,267,857 31,267,857 (+0.00%) 20,610,037 20,610,037 (+0.00%) 0 0 (+0.00%) 2,664,455 2,664,455 (+0.00%)
precompiles p256_verify 748,861 748,861 (+0.00%) 470,169 470,169 (+0.00%) 0 0 (+0.00%) 69,673 69,673 (+0.00%)
precompiles process_block 147,545,247 147,547,775 (+0.00%) 118,066,111 118,080,503 (+0.01%) 5,160 5,160 (+0.00%) 7,349,144 7,346,178 (-0.04%)
precompiles process_transaction 73,482,359 73,479,462 (-0.00%) 58,781,919 58,786,430 (+0.01%) 160 160 (+0.00%) 3,674,470 3,672,618 (-0.05%)
precompiles ripemd 8,013 8,013 (+0.00%) 8,013 8,013 (+0.00%) 0 0 (+0.00%) 0 0 (+0.00%)
precompiles run_tx_loop 146,893,585 146,895,908 (+0.00%) 117,494,129 117,508,316 (+0.01%) 180 180 (+0.00%) 7,349,144 7,346,178 (-0.04%)
precompiles sha256 13,168 13,168 (+0.00%) 13,168 13,168 (+0.00%) 0 0 (+0.00%) 0 0 (+0.00%)
precompiles system_init 46,785 46,785 (+0.00%) 46,785 46,785 (+0.00%) 0 0 (+0.00%) 0 0 (+0.00%)
precompiles verify_and_apply_batch 146,522 146,522 (+0.00%) 110,202 110,202 (+0.00%) 2,270 2,270 (+0.00%) 0 0 (+0.00%)

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a repo-root profile.sh helper script to measure peak heap memory usage during the transactions::run_base_system e2e test run and produce a speedscope-compatible flamegraph input.

Changes:

  • Introduces profile.sh to build the transactions test binary in release mode and record allocations with heaptrack.
  • Extracts peak-memory flamegraph stacks via heaptrack_print and demangles symbols with rustfilt.
  • Adds basic CLI usage/help output and dependency checks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread profile.sh
Comment thread profile.sh
echo "==> Recording heap profile -> ${OUTPUT_FILE}.zst (test logs: ${TEST_LOG})..."
heaptrack --record-only -o "$OUTPUT_FILE" \
"$TEST_BIN" --exact run_base_system --nocapture \
2>&1 > "$TEST_LOG"
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stdout/stderr redirection order is wrong here: 2>&1 > "$TEST_LOG" sends stderr to the terminal and only stdout to the log. If the intent is to capture all test output in the log file, redirect stdout first and then stderr (or use a single combined redirection).

Suggested change
2>&1 > "$TEST_LOG"
> "$TEST_LOG" 2>&1

Copilot uses AI. Check for mistakes.
Comment thread profile.sh
Comment thread profile.sh
Comment thread profile.sh
Comment thread profile.sh
fi

if [[ -z "${1:-}" ]]; then
echo "Error: test name argument is required." >&2
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message says “test name argument”, but the required positional argument is a label used for output file names. Align the wording with the usage text to avoid confusion.

Suggested change
echo "Error: test name argument is required." >&2
echo "Error: label argument is required." >&2

Copilot uses AI. Check for mistakes.
Comment thread profile.sh
@@ -0,0 +1,138 @@
#!/bin/bash

# set -euo pipefail
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the script doesn’t enable set -e/pipefail (and also doesn’t manually check exit codes), failures in cargo test, heaptrack, heaptrack_print, or rustfilt can be silently ignored and still produce a “Done” message. Consider enabling strict mode (or explicitly checking command exit codes) so profiling failures fail fast.

Suggested change
# set -euo pipefail
set -euo pipefail

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is intentionally left out to be able to produce results even when the test OOMs

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.

2 participants