Skip to content
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4615da8
setup gungraun
mattiapitossi Dec 13, 2025
2f1ad53
setup gungraun
mattiapitossi Dec 13, 2025
747a0ab
Merge branch 'tokio-rs:master' into gungraun-6539
mattiapitossi Dec 13, 2025
65b527c
fix valgrind setup
mattiapitossi Dec 13, 2025
fad576e
feat: ci
mattiapitossi Dec 16, 2025
77ed51d
remove comment
mattiapitossi Dec 17, 2025
a277627
add bench on pr
mattiapitossi Dec 17, 2025
da95320
Merge branch 'master' into gungraun-6539
mattiapitossi Dec 17, 2025
e034e81
use 100 as capacity for spawn
mattiapitossi Dec 17, 2025
90dc801
using only cache
mattiapitossi Dec 17, 2025
cf22473
trigger pipeline
mattiapitossi Dec 17, 2025
0309720
store artifact for comparison
mattiapitossi Dec 18, 2025
7bec750
trigger pipeline
mattiapitossi Dec 18, 2025
e451312
restore previous data from cache
mattiapitossi Dec 18, 2025
5349f11
trigger pipeline
mattiapitossi Dec 18, 2025
099a551
add comment on regression
mattiapitossi Dec 18, 2025
0e1f534
trigger pipeline
mattiapitossi Dec 18, 2025
b935078
Merge branch 'master' into gungraun-6539
mattiapitossi Dec 18, 2025
d498ac2
fix path
mattiapitossi Dec 18, 2025
c220ca1
trigger pipeline
mattiapitossi Dec 18, 2025
b27c287
fix path
mattiapitossi Dec 18, 2025
b24bda6
add comment on regression
mattiapitossi Dec 18, 2025
b30de42
remove benchmarks on pr after testing
mattiapitossi Dec 18, 2025
399c3df
trigger pipeline
mattiapitossi Dec 18, 2025
3790d7c
replace benchmark tool output with bencher
mattiapitossi Dec 25, 2025
f254fff
Merge branch 'master' into gungraun-6539
mattiapitossi Dec 25, 2025
ebb5627
add docs
mattiapitossi Dec 25, 2025
5ea56ec
format docs
mattiapitossi Dec 25, 2025
a84dd9f
add permission to post benchmark results
mattiapitossi Jan 2, 2026
49c3757
Merge branch 'master' into gungraun-6539
mattiapitossi Jan 2, 2026
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
34 changes: 34 additions & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: benchmark
on:
push:
branches:
- master

jobs:
benchmark:
name: Benchmark
runs-on: ubuntu-latest
env:
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
strategy:
matrix:
bench:
- ct_spawn
steps:
- uses: actions/checkout@v5

- run: sudo apt-get update && sudo apt-get install -y valgrind

- uses: taiki-e/install-action@cargo-binstall
- name: Install gungraun-runner
run: |
version=$(cargo metadata --format-version=1 |\
jq '.packages[] | select(.name == "gungraun").version' |\
tr -d '"'
)
cargo binstall --no-confirm gungraun-runner --version $version

- uses: bencherdev/bencher@main
- name: Run Bencher
run: |
bencher run --adapter rust_gungraun --err "cargo bench --bench ${{ matrix.bench }}"
Copy link
Copy Markdown
Member Author

@mattiapitossi mattiapitossi Dec 25, 2025

Choose a reason for hiding this comment

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

TODO: There's an open discussion on Discord whether we want to use Bencher or not

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can try using bencher. I understand that we need to do something special to set it up. Could you share more details on what is required?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure! Technically, it should be enough to create an account on https://bencher.dev/auth/signup and generate an API token. Then, a new secret called BENCHER_API_TOKEN with the API key should be created under repo settings as described here

7 changes: 7 additions & 0 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ license = "MIT"
[features]
test-util = ["tokio/test-util"]


[dependencies]
tokio = { version = "1.5.0", path = "../tokio", features = ["full"] }
criterion = "0.5.1"
gungraun = "0.17.0"
rand = "0.9"
rand_chacha = "0.9"

Expand Down Expand Up @@ -101,5 +103,10 @@ name = "spawn_blocking"
path = "spawn_blocking.rs"
harness = false

[[bench]]
name = "ct_spawn"
path = "ct_spawn.rs"
harness = false

[lints]
workspace = true
62 changes: 62 additions & 0 deletions benches/ct_spawn.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
use gungraun::{library_benchmark, library_benchmark_group, main};
use std::hint::black_box;
use tokio::runtime::Runtime;

fn single_rt() -> tokio::runtime::Runtime {
tokio::runtime::Builder::new_current_thread()
.build()
.unwrap()
}

fn multi_rt() -> tokio::runtime::Runtime {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(1)
.build()
.unwrap()
}

async fn work() -> usize {
let val = 1 + 1;
tokio::task::yield_now().await;
black_box(val)
}

fn spawn(runtime: Runtime) {
runtime.block_on(async {
let h = tokio::spawn(work());
assert_eq!(h.await.unwrap(), 2);
});
}

fn spawn100(runtime: Runtime) {
runtime.block_on(async {
let mut handles = Vec::with_capacity(100);
for _ in 0..100 {
handles.push(tokio::spawn(work()));
}
for handle in handles {
assert_eq!(handle.await.unwrap(), 2);
}
});
}

#[library_benchmark]
#[bench::basic(setup = single_rt)]
#[bench::threaded(setup = multi_rt)]
fn spawn_rt(runtime: Runtime) {
black_box(spawn(runtime));
}

#[library_benchmark]
#[bench::basic(setup = single_rt)]
#[bench::threaded(setup = multi_rt)]
fn spawn_rt_100(runtime: Runtime) {
black_box(spawn100(runtime));
}

library_benchmark_group!(
name = group;
benchmarks = spawn_rt,spawn_rt_100
);

main!(library_benchmark_groups = group);
Loading