Skip to content

feat(reexecution): add optional profiling support to benchmarking script - #4791

Closed
Elvis339 wants to merge 2 commits into
masterfrom
es/reexecute-cross-stack-profiling
Closed

feat(reexecution): add optional profiling support to benchmarking script#4791
Elvis339 wants to merge 2 commits into
masterfrom
es/reexecute-cross-stack-profiling

Conversation

@Elvis339

@Elvis339 Elvis339 commented Dec 25, 2025

Copy link
Copy Markdown
Contributor

Why this should be merged

This patch is part of: ava-labs/firewood#1582

Adds profiling support to the C-Chain re-execution benchmark, enabling visibility into Rust FFI performance when using Firewood. When PROFILE=true, the binary is built with debug symbols and frame pointers, allowing profilers (pprof, perf, samply, Instruments) to resolve function names across the Go → CGO → Rust stack instead of showing opaque memory addresses.

How this works

When PROFILE=true is set:

  1. Go build flags disable optimizations (-N) and inlining (-l) to preserve stack traces
  2. DWARF debug info is kept uncompressed for profiler compatibility
  3. CGO flags enable frame pointers and debug symbols for Rust FFI visibility
  4. Binary is built to /tmp/vm_reexecute for post-run analysis

How this was tested

1. Baseline - build without profiling flags

# Build Go binary without profiling flags
go build -o /tmp/vm_reexecute \
  github.com/ava-labs/avalanchego/tests/reexecute/c

# Check for Rust debug info
dwarfdump --debug-info /tmp/vm_reexecute 2>/dev/null | grep -E "firewood::|storage::" | head -5

Output shows no Rust debug info

(no output)

2. Build WITH profiling flags:

# Sync Firewood at the required commit (includes profiling Nix package)
go run github.com/ava-labs/avalanchego/tests/fixture/polyrepo@6239973c9b \
  sync firewood@1dc00532d977c45d22cd5939cd5a692218c5ec94

# Build FFI with profiling (debug symbols + frame pointers)
cd firewood/ffi && rm -rf result && nix build .#profile
cd ../..

CGO_CFLAGS="-fno-omit-frame-pointer -g" \
go build -o /tmp/vm_reexecute \
  -gcflags="all=-N -l" \
  -ldflags="-compressdwarf=false" \
  github.com/ava-labs/avalanchego/tests/reexecute/c

# Check for Rust debug info
dwarfdump --debug-info /tmp/vm_reexecute 2>/dev/null | grep -E "firewood::|storage::" | head -10

Output shows resolved Rust type/function names:

DW_AT_type  (0x00af9e0b "core::result::Result<core::option::Option<firewood_storage::hashtype::trie_hash::TrieHash>, firewood::v2::api::Error>")
DW_AT_name  ("impl FnOnce() -> Result<firewood::db::Proposal<'db>, api::Error>")
DW_AT_type  (0x00af6bb2 "core::option::Option<firewood_storage::hashtype::trie_hash::TrieHash>")
DW_AT_type  (0x00b08ede "firewood::db::Proposal")
DW_AT_type  (0x00afa078 "core::result::Result<firewood_ffi::proposal::CreateProposalResult, firewood::v2::api::Error>")

This enables profilers to display human-readable Rust call stacks instead of raw memory addresses.

If empty output run:

cd firewood/ffi && nix-collect-garbage && \ 
    rm -rf /tmp/vm_reexecute && \
    nix build .#profile && \
    CGO_CFLAGS="-fno-omit-frame-pointer -g" \
    go build -o /tmp/vm_reexecute \
        -gcflags="all=-N -l" \
       -ldflags="-compressdwarf=false" \
       github.com/ava-labs/avalanchego/tests/reexecute/c

Need to be documented in RELEASES.md?

No

${METRICS_SERVER_ENABLED:+--metrics-server-enabled="${METRICS_SERVER_ENABLED}"} \
${METRICS_SERVER_PORT:+--metrics-server-port="${METRICS_SERVER_PORT}"} \
${METRICS_COLLECTOR_ENABLED:+--metrics-collector-enabled="${METRICS_COLLECTOR_ENABLED}"}
# ${PROFILE:+--pprof}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Requires merging #4790

@github-actions

github-actions Bot commented Feb 1, 2026

Copy link
Copy Markdown

This PR has become stale because it has been open for 30 days with no activity. Adding the lifecycle/frozen label will cause this PR to ignore lifecycle events.

@github-actions github-actions Bot added the lifecycle/stale Inactive for 60 days label Feb 1, 2026
@github-actions

github-actions Bot commented Apr 5, 2026

Copy link
Copy Markdown

This PR is being closed due to no activity. Please re-open if this needs to be prioritized.

@github-actions github-actions Bot added the lifecycle/rotten Automatically closed due to inactivity label Apr 5, 2026
@github-actions github-actions Bot closed this Apr 5, 2026
@github-project-automation github-project-automation Bot moved this to Done 🎉 in avalanchego Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lifecycle/rotten Automatically closed due to inactivity lifecycle/stale Inactive for 60 days

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant