Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,16 @@ jobs:
with:
tool: cargo-codspeed

- name: Install libbpf build deps
run: sudo apt-get update && sudo apt-get install -y build-essential pkgconf zlib1g-dev libbpf-dev autopoint bison flex

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.

there is quite a lot of duplication to install build time dependencies of memtrack across the whole workflow, cnat we create a install-bpf-deps local action?

Dont bundle biuld-essential with it, first check if it's required here, and if it's required here, add it as either a separate step, or an additional-packages action input


- name: Build benchmarks
run: cargo codspeed build -p runner-shared
run: cargo codspeed build -p runner-shared -p memtrack
- name: Run benchmarks
uses: CodSpeedHQ/action@3194d9a39c4d46684cb44bf7207fc56626aad8fd # v4
with:
mode: simulation
run: cargo codspeed run -p runner-shared
run: cargo codspeed run -p runner-shared -p memtrack

check:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions crates/memtrack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ paste = "1.0.15"
libbpf-rs = { version = "0.26", features = ["vendored"], optional = true }
glob = "0.3.3"
object = { workspace = true }
rayon = "1.12"

[build-dependencies]
libbpf-cargo = { version = "0.26", optional = true }
Expand All @@ -46,6 +47,11 @@ rstest = { workspace = true }
test-log = { workspace = true }
insta = { workspace = true }
test-with = { workspace = true }
divan = { package = "codspeed-divan-compat", version = "4" }

[[bench]]
name = "attach"
harness = false

[package.metadata.dist]
targets = ["aarch64-unknown-linux-gnu", "x86_64-unknown-linux-gnu"]
Expand Down
36 changes: 36 additions & 0 deletions crates/memtrack/benches/attach.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use memtrack::{AllocatorLib, resolve_symbol_offsets};

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.

shouldnt these run on vendored allocator libs as part of a testdata folder instead of relying on the host machine's allocator?

use rayon::prelude::*;

fn main() {
divan::main();
}

fn discovered_allocators() -> Vec<AllocatorLib> {
let libs = AllocatorLib::find_all().expect("failed to discover allocators");
assert!(!libs.is_empty(), "no allocators discovered");
libs
}

/// Resolve symbol offsets for every discovered allocator one library at a time.
#[divan::bench]
fn resolve_offsets_serial(bencher: divan::Bencher) {
let libs = discovered_allocators();

bencher.bench_local(|| {
libs.iter()
.map(|lib| resolve_symbol_offsets(&lib.path).expect("failed to resolve offsets"))
.collect::<Vec<_>>()
});
}

/// Resolve symbol offsets for every discovered allocator in parallel.
#[divan::bench]
fn resolve_offsets_parallel(bencher: divan::Bencher) {
let libs = discovered_allocators();

bencher.bench_local(|| {
libs.par_iter()
.map(|lib| resolve_symbol_offsets(&lib.path).expect("failed to resolve offsets"))
.collect::<Vec<_>>()
});
}
Loading
Loading