-
-
Notifications
You must be signed in to change notification settings - Fork 3k
ci: Run benchmarks in the CI #7779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mattiapitossi
wants to merge
30
commits into
tokio-rs:master
Choose a base branch
from
mattiapitossi:gungraun-6539
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+122
−3
Open
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
4615da8
setup gungraun
mattiapitossi 2f1ad53
setup gungraun
mattiapitossi 747a0ab
Merge branch 'tokio-rs:master' into gungraun-6539
mattiapitossi 65b527c
fix valgrind setup
mattiapitossi fad576e
feat: ci
mattiapitossi 77ed51d
remove comment
mattiapitossi a277627
add bench on pr
mattiapitossi da95320
Merge branch 'master' into gungraun-6539
mattiapitossi e034e81
use 100 as capacity for spawn
mattiapitossi 90dc801
using only cache
mattiapitossi cf22473
trigger pipeline
mattiapitossi 0309720
store artifact for comparison
mattiapitossi 7bec750
trigger pipeline
mattiapitossi e451312
restore previous data from cache
mattiapitossi 5349f11
trigger pipeline
mattiapitossi 099a551
add comment on regression
mattiapitossi 0e1f534
trigger pipeline
mattiapitossi b935078
Merge branch 'master' into gungraun-6539
mattiapitossi d498ac2
fix path
mattiapitossi c220ca1
trigger pipeline
mattiapitossi b27c287
fix path
mattiapitossi b24bda6
add comment on regression
mattiapitossi b30de42
remove benchmarks on pr after testing
mattiapitossi 399c3df
trigger pipeline
mattiapitossi 3790d7c
replace benchmark tool output with bencher
mattiapitossi f254fff
Merge branch 'master' into gungraun-6539
mattiapitossi ebb5627
add docs
mattiapitossi 5ea56ec
format docs
mattiapitossi a84dd9f
add permission to post benchmark results
mattiapitossi 49c3757
Merge branch 'master' into gungraun-6539
mattiapitossi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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_TOKENwith the API key should be created under repo settings as described here