Skip to content

feat: speedup ebpf uprobe attaching#440

Open
not-matthias wants to merge 4 commits into
mainfrom
cod-3070-speedup-allocator-attaching-on-nixos
Open

feat: speedup ebpf uprobe attaching#440
not-matthias wants to merge 4 commits into
mainfrom
cod-3070-speedup-allocator-attaching-on-nixos

Conversation

@not-matthias

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

Copy link
Copy Markdown
Member

No description provided.

@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown

Greptile Summary

This PR speeds up memtrack’s eBPF allocator setup and teardown. The main changes are:

  • Resolves allocator symbol offsets before attaching probes.
  • Attaches allocator libraries through a batched memtrack path.
  • Detaches BPF links explicitly and in parallel during shutdown.
  • Moves BPF build dependency installation into a reusable GitHub Action.
  • Adds rayon for parallel symbol-resolution work.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
crates/memtrack/src/ebpf/memtrack.rs Refactors allocator probe attachment around resolved file offsets and adds parallel BPF link detach.
crates/memtrack/src/main.rs Disables tracking and detaches probes explicitly before reading the dropped-event counter.
crates/memtrack/src/ebpf/tracker.rs Delegates allocator attachment to the BPF layer and exposes explicit detach.
.github/workflows/ci.yml Uses the shared BPF dependency installation action in CI.
.github/actions/install-bpf-deps/action.yml Adds a composite action for installing vendored libbpf build dependencies.

Reviews (12): Last reviewed commit: "perf(memtrack): detach BPF links in para..." | Re-trigger Greptile

Comment thread crates/memtrack/src/ebpf/memtrack.rs Outdated
Comment thread crates/memtrack/src/ebpf/memtrack.rs Outdated
Comment thread crates/memtrack/src/ebpf/memtrack.rs Outdated
@codspeed-hq

codspeed-hq Bot commented Jul 7, 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.

✅ 7 untouched benchmarks


Comparing cod-3070-speedup-allocator-attaching-on-nixos (705245d) with main (58d994a)

Open in CodSpeed

@not-matthias not-matthias force-pushed the cod-3070-speedup-allocator-attaching-on-nixos branch from 0e8688a to 3a322ae Compare July 7, 2026 17:07
Comment thread crates/memtrack/src/ebpf/memtrack.rs Outdated
@not-matthias not-matthias marked this pull request as ready for review July 7, 2026 17:47
@not-matthias not-matthias force-pushed the cod-3070-speedup-allocator-attaching-on-nixos branch from 3a322ae to 9f32601 Compare July 8, 2026 17:18

@GuillaumeLagrange GuillaumeLagrange left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

small changes, olgtm

Comment thread crates/memtrack/src/ebpf/memtrack.rs Outdated
Comment thread crates/memtrack/src/ebpf/memtrack.rs Outdated
Comment thread crates/memtrack/src/ebpf/memtrack.rs Outdated
Comment thread crates/memtrack/src/ebpf/memtrack.rs Outdated
Comment thread crates/memtrack/benches/attach.rs Outdated
Comment thread .github/workflows/ci.yml Outdated
@not-matthias not-matthias force-pushed the cod-3070-speedup-allocator-attaching-on-nixos branch from 9f32601 to 5784734 Compare July 13, 2026 12:38
Comment thread crates/memtrack/src/ebpf/memtrack.rs
@not-matthias not-matthias force-pushed the cod-3070-speedup-allocator-attaching-on-nixos branch from 5784734 to aaea537 Compare July 13, 2026 13:19
Comment thread crates/memtrack/src/ebpf/memtrack.rs
@not-matthias not-matthias force-pushed the cod-3070-speedup-allocator-attaching-on-nixos branch 3 times, most recently from adc9941 to 29e1d27 Compare July 13, 2026 15:27
Comment thread crates/memtrack/src/ebpf/memtrack.rs Outdated
Comment thread crates/memtrack/src/ebpf/memtrack.rs Outdated
@not-matthias not-matthias force-pushed the cod-3070-speedup-allocator-attaching-on-nixos branch from 711ffef to ddaad66 Compare July 13, 2026 16:26
…f func_name

Resolve every defined symbol's libbpf-compatible file offset once per
library (st_value - sh_addr + sh_offset) and attach uprobes by offset,
replacing the per-probe func_name lookup that reparsed the ELF each time.
Symbol resolution parses each allocator ELF independently, so fan it out
across cores with rayon before the serial attach step. Cuts offset
resolution for all discovered allocators from ~190ms to ~29ms locally.
Closing a uprobe link fd blocks on two RCU grace periods in the kernel,
serialized per link (~1,200 links = ~50s teardown). Concurrent waiters
share grace periods, so closing from 32 threads scales near-linearly.

The tracker must be detached explicitly in track_command: the IPC thread
holds an Arc clone, so the tracker is never dropped before process::exit
and the kernel would close every link fd serially during exit. Tracking
is disabled right after the child exits so draining and artifact writes
happen before the expensive detach.
@not-matthias not-matthias force-pushed the cod-3070-speedup-allocator-attaching-on-nixos branch from ddaad66 to 705245d Compare July 13, 2026 16:38
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