Skip to content
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

bench: add bench action #173

Merged
merged 20 commits into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from 14 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
81 changes: 23 additions & 58 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Do not run this workflow on pull request since this workflow has permission to modify contents.
on:
workflow_dispatch:
inputs:
reason:
description: 'reason to trigger this build'
required: false

push:
branches:
- master

permissions:
# deployments permission to deploy GitHub pages website
deployments: write
# contents permission to update benchmark contents in gh-pages branch
contents: write

name: Bench

jobs:
Expand All @@ -26,55 +31,15 @@ jobs:
with:
toolchain: nightly
default: true
- uses: actions-rs/cargo@v1
name: Benchmark 🚀
with:
command: bench
args: --all-features --workspace
sanitizer_bench:
name: Bench with Sanitizer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
name: Checkout 🛎️
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-sanitizer-bench
- uses: actions-rs/toolchain@v1
name: Setup Cargo Toolchain 🛎️
with:
components: rust-src
toolchain: nightly
default: true
- uses: actions-rs/cargo@v1
name: Bench with Address Sanitizer 🚀
with:
command: bench
args: --all-features -Zbuild-std --target x86_64-unknown-linux-gnu
env:
RUSTFLAGS: "-Zsanitizer=address"
- uses: actions-rs/cargo@v1
name: Bench with Leak Sanitizer 🚀
with:
command: bench
args: --all-features -Zbuild-std --target x86_64-unknown-linux-gnu
env:
RUSTFLAGS: "-Zsanitizer=leak"
- uses: actions-rs/cargo@v1
name: Bench with Memory Sanitizer 🚀
with:
command: bench
args: --all-features -Zbuild-std --target x86_64-unknown-linux-gnu
env:
RUSTFLAGS: "-Zsanitizer=memory"
- uses: actions-rs/cargo@v1
name: Bench with Thread Sanitizer 🚀
with:
command: bench
args: --all-features -Zbuild-std --target x86_64-unknown-linux-gnu
env:
RUSTFLAGS: "-Zsanitizer=thread"
- name: Benchmark 🚀
run: cargo +nightly bench --all-features --workspace --bench benches_agate_rocks -- --output-format bencher | tee output.txt
- uses: benchmark-action/github-action-benchmark@v1
name: Store benchmark result
with:
name: Benchmark with RocksDB
tool: "cargo"
output-file-path: output.txt
# Access token to deploy GitHub Pages branch
github-token: ${{ secrets.GITHUB_TOKEN }}
# Push and deploy GitHub pages branch automatically
auto-push: true
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ version = "0.1.0"
authors = ["Jay Lee <busyjaylee@gmail.com>"]
edition = "2018"

[features]
default = []
enable-rocksdb = ["rocksdb"]

[dependencies]
bytes = "1.0"
coarsetime = "0.1.22"
Expand All @@ -20,6 +24,7 @@ parking_lot = "0.11"
prost = "0.8"
proto = { path = "proto" }
rand = "0.7"
rocksdb = { version = "0.15", optional = true }
skiplist = { path = "skiplist" }
tempdir = "0.3"
thiserror = "1.0"
Expand Down Expand Up @@ -51,6 +56,10 @@ harness = false
name = "bench_iterator"
harness = false

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

[profile.bench]
opt-level = 3
debug = false
Expand Down
12 changes: 7 additions & 5 deletions agate_bench/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use std::{
path::PathBuf,
sync::{mpsc::channel, Arc},
time::{Duration, UNIX_EPOCH},
};

use agatedb::{AgateOptions, IteratorOptions};
use bytes::{Bytes, BytesMut};
use clap::clap_app;
use indicatif::{ProgressBar, ProgressStyle};
use rand::Rng;
use std::path::PathBuf;
use std::sync::Arc;
use std::time::UNIX_EPOCH;
use std::{sync::mpsc::channel, time::Duration};

#[cfg(not(target_env = "msvc"))]
use tikv_jemallocator::Jemalloc;

Expand Down Expand Up @@ -134,6 +135,7 @@ fn main() {

let mut options = AgateOptions {
create_if_not_exists: true,
sync_writes: true,
dir: directory.clone(),
value_dir: directory,
managed_txns: true,
Expand Down
10 changes: 3 additions & 7 deletions benches/bench_iterator.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
mod common;

use agatedb::util::unix_time;
use agatedb::AgateIterator;
use agatedb::AgateOptions;
use agatedb::ConcatIterator;
use agatedb::Iterators;
use agatedb::MergeIterator;

use agatedb::{
util::unix_time, AgateIterator, AgateOptions, ConcatIterator, Iterators, MergeIterator,
};
use bytes::Bytes;
use common::get_table_for_benchmark;
use criterion::{criterion_group, criterion_main, Criterion};
Expand Down
Loading