Skip to content

feat(memtrack): support CODSPEED_MEMTRACK_BINARIES for exec CLI#266

Open
not-matthias wants to merge 1 commit intomainfrom
cod-2347-clarify-spawned-process-limitation-of-memory-instrument
Open

feat(memtrack): support CODSPEED_MEMTRACK_BINARIES for exec CLI#266
not-matthias wants to merge 1 commit intomainfrom
cod-2347-clarify-spawned-process-limitation-of-memory-instrument

Conversation

@not-matthias
Copy link
Member

Summary

  • Add CODSPEED_MEMTRACK_BINARIES env var support in memtrack to scan additional binaries for statically linked allocators
  • Auto-set the env var in the exec CLI by resolving exec target binary paths with which
  • Merge with any user-provided value to allow manual override

Fixes COD-2347

Context

Memory profiling doesn't work with exec CLI when the benchmark binary has a statically linked allocator (common in Rust). Memtrack discovers allocators by scanning known build directories (target/codspeed/analysis, bazel-bin, build), but exec CLI binaries may not live there.

Test plan

  • cargo check / cargo clippy clean
  • cargo test passes (174 passed, 0 failed)
  • Manual: codspeed exec -m memory -- ./binary_with_static_allocator — verify memtrack logs show the extra allocator

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 16, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks


Comparing cod-2347-clarify-spawned-process-limitation-of-memory-instrument (0abb534) with main (3e90ed6)

Open in CodSpeed

Copy link

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 support for discovering statically linked allocators in codspeed exec targets by passing exec-resolved binaries to memtrack via a new CODSPEED_MEMTRACK_BINARIES environment variable.

Changes:

  • Auto-resolve exec target binaries (via which) and set/merge CODSPEED_MEMTRACK_BINARIES in the exec CLI.
  • Extend memtrack allocator discovery to scan binaries listed in CODSPEED_MEMTRACK_BINARIES.
  • Add dependencies (which, temp-env) and update lockfile accordingly.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/cli/exec/mod.rs Resolves exec target binary paths and sets/merges CODSPEED_MEMTRACK_BINARIES before orchestrator execution.
crates/memtrack/src/allocators/mod.rs Adds allocator discovery from env-specified binaries and wires it into AllocatorLib::find_all().
crates/memtrack/Cargo.toml Adds temp-env as a dev-dependency (intended for tests).
Cargo.toml Adds which dependency to support binary path resolution.
Cargo.lock Updates dependency graph for which and adds temp-env.

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

You can also share your feedback on Copilot code review. Take the survey.

@not-matthias not-matthias force-pushed the cod-2347-clarify-spawned-process-limitation-of-memory-instrument branch from d0e19a2 to 90409e0 Compare March 16, 2026 18:12
@not-matthias not-matthias changed the base branch from main to cod-2309-walltime-benchmarks-with-flamegraphs March 16, 2026 18:13
@not-matthias not-matthias changed the base branch from cod-2309-walltime-benchmarks-with-flamegraphs to main March 16, 2026 18:13
…or discovery

Memtrack discovers allocators by scanning known build directories, but
exec CLI binaries may not live there. This causes memory profiling to
miss allocations when the binary has a statically linked allocator
(common in Rust).

Add CODSPEED_MEMTRACK_BINARIES env var (colon-separated paths) that
tells memtrack additional binaries to scan. The exec CLI auto-sets it
by resolving exec target binary paths before execution.

COD-2347
@not-matthias not-matthias force-pushed the cod-2347-clarify-spawned-process-limitation-of-memory-instrument branch from 90409e0 to 0abb534 Compare March 16, 2026 18:16
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