Skip to content

feat: add --track-allocators toggle for memory mode#469

Open
not-matthias wants to merge 1 commit into
cod-3089-collect-rss-in-memtrackfrom
cod-3231-support-disabling-allocator-tracking
Open

feat: add --track-allocators toggle for memory mode#469
not-matthias wants to merge 1 commit into
cod-3089-collect-rss-in-memtrackfrom
cod-3231-support-disabling-allocator-tracking

Conversation

@not-matthias

@not-matthias not-matthias commented Jul 24, 2026

Copy link
Copy Markdown
Member

What

Adds a --track-allocators flag (default on, env CODSPEED_TRACK_ALLOCATORS) on run/exec and the memtrack track subcommand. When disabled (--track-allocators false), memtrack skips the per-allocation uprobe machinery and only emits coarse mmap/munmap/brk events.

Why

Allocation-heavy programs (e.g. a Rust build) generate an overwhelming number of malloc/free events, and the per-allocation uprobes slow the target significantly. This flag lets users trade allocation granularity for lower overhead while still collecting RSS-relevant memory events.

How

  • memtrack: the mmap/munmap/brk syscall tracepoints (already compiled into the BPF program but never attached) are now always attached in every memory run. The flag gates only the expensive allocator uprobes (exec-mapping watcher + attach worker).
  • Tracker::new(track_allocators: bool) conditionally starts the exec watcher / AttachWorker; spawn/finish tolerate a None worker.
  • runner: flag lives on ExecAndRunSharedArgs, threaded through OrchestratorConfigExecutorConfig (mirroring exclude_allocations), and passed to the memtrack subprocess as an explicit --track-allocators <bool> arg (not via env inheritance, to survive glibc secure-execution env stripping).

Default runs are unchanged in allocation coverage and now additionally emit mmap/brk events.

Testing

  • cargo check --workspace --tests, cargo test --release -p codspeed-runner — green.
  • CLI surface verified: run/exec/memtrack track --help show the flag (default true); CODSPEED_TRACK_ALLOCATORS=false parses.
  • New CI-gated integration test (test_track_allocators_disabled_skips_allocations) asserts that with allocators disabled, the trace contains Mmap events and zero allocation-kind events.

Fixes COD-3231.

@greptile-apps

greptile-apps Bot commented Jul 24, 2026

Copy link
Copy Markdown

Greptile Summary

Adds configurable allocator tracking alongside expanded RSS accounting.

  • Adds --track-allocators support and conditionally disables allocator uprobes while retaining coarse memory events.
  • Adds eBPF RSS, reverse-mapping, and process-lifecycle event collection.
  • Extends shared memtrack event schemas and reconstruction logic for the new event types.
  • Adds architecture-matrix CI coverage and RSS integration fixtures and snapshots.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failures remain within the follow-up review scope.

No blocking failures remain.

Important Files Changed

Filename Overview
crates/memtrack/src/ebpf/tracker.rs Makes allocator attachment optional while retaining the common tracker lifecycle and tracepoint setup.
crates/memtrack/src/ebpf/c/rss.bpf.h Introduces RSS, reverse-mapping, fork, exec, and exit event collection with process ownership tracking.
crates/memtrack/src/ebpf/memtrack/tracking.rs Attaches syscall, RSS, lifecycle, and supported reverse-mapping probes.
crates/memtrack/src/main.rs Exposes the allocator-tracking toggle and passes it into tracker construction.
crates/runner-shared/src/artifacts/memtrack/mod.rs Extends the shared memtrack artifact schema for RSS and process-lifecycle events.
.github/workflows/ci.yml Expands eBPF integration coverage across x86-64 and ARM runners and adds RSS tests.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    CLI[run / exec / memtrack CLI] --> CFG[track_allocators configuration]
    CFG --> TRACKER[Tracker]
    TRACKER --> TRACE[Always-attached syscall and lifecycle tracepoints]
    CFG -->|true| UPROBES[Allocator watcher and uprobes]
    CFG -->|false| SKIP[Skip allocator uprobes]
    TRACE --> EVENTS[Memtrack events]
    UPROBES --> EVENTS
    EVENTS --> ARTIFACT[runner-shared artifact encoding]
Loading

Reviews (3): Last reviewed commit: "feat: add --track-allocators toggle for ..." | Re-trigger Greptile

@codspeed-hq

codspeed-hq Bot commented Jul 24, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 17 untouched benchmarks


Comparing cod-3231-support-disabling-allocator-tracking (131f8a3) with main (26fb4b5)

Open in CodSpeed

@not-matthias
not-matthias force-pushed the cod-3231-support-disabling-allocator-tracking branch from 27cfce8 to d983261 Compare July 24, 2026 09:23
Add a --track-allocators flag (default on, env CODSPEED_TRACK_ALLOCATORS)
to the memtrack track subcommand. When disabled, memtrack skips the
allocator uprobe machinery (exec watcher + attach worker) and only emits
coarse mmap/munmap/brk events, reducing overhead on allocation-heavy
programs. The mmap/munmap/brk syscall tracepoints are now always attached
in every memory run.

The runner does not add a CLI flag for this: it relies on the
CODSPEED_TRACK_ALLOCATORS environment variable being inherited by the
memtrack subprocess, keeping the runner decoupled from the installed
memtrack version. Standalone memtrack can still use the CLI flag.
@not-matthias
not-matthias force-pushed the cod-3231-support-disabling-allocator-tracking branch from d983261 to 131f8a3 Compare July 24, 2026 10:40
@not-matthias
not-matthias changed the base branch from main to cod-3089-collect-rss-in-memtrack July 24, 2026 12:04
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.

1 participant