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

Fix/bench results #800

Merged
merged 8 commits into from Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
64 changes: 16 additions & 48 deletions .github/workflows/bench.yml
Expand Up @@ -6,23 +6,32 @@ on:
- dev
workflow_dispatch:

env:
RUST_BACKTRACE: 1
CARGO_PROFILE_DEV_DEBUG: 0 # This would add unnecessary bloat to the target folder, decreasing cache efficiency.
LC_ALL: en_US.UTF-8 # This prevents strace from changing it's number format to use commas.

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
bench:
strategy:
fail-fast: false
matrix:
rust_version: [stable]
rust: [nightly]
platform:
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }

runs-on: ${{ matrix.platform.os }}

steps:
- uses: actions/checkout@v2
- name: install stable
- name: install ${{ matrix.rust }}
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
toolchain: ${{ matrix.rust }}
override: true
components: rust-src
target: ${{ matrix.platform.target }}
Expand All @@ -42,52 +51,11 @@ jobs:
sudo dpkg -i hyperfine_1.11.0_amd64.deb
pip install memory_profiler

- name: get current date
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV

- name: cache cargo registry
uses: actions/cache@v2.1.4
with:
path: ~/.cargo/registry
# Add date to the cache to keep it up to date
key: ${{ matrix.platform }}-stable-cargo-registry-${{ hashFiles('Cargo.toml') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.platform }}-stable-cargo-registry-${{ hashFiles('Cargo.toml') }}
${{ matrix.platform }}-stable-cargo-registry-

- name: cache cargo index
uses: actions/cache@v2.1.4
with:
path: ~/.cargo/git
# Add date to the cache to keep it up to date
key: ${{ matrix.platform }}-stable-cargo-index-${{ hashFiles('Cargo.toml') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.platform }}-stable-cargo-index-${{ hashFiles('Cargo.toml') }}
${{ matrix.platform }}-stable-cargo-index-

- name: cache cargo target
uses: actions/cache@v2
with:
path: target
# Add date to the cache to keep it up to date
key: ${{ matrix.platform }}-stable-cargo-core-${{ hashFiles('Cargo.toml') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.platform }}-stable-cargo-core-${{ hashFiles('Cargo.toml') }}
${{ matrix.platform }}-stable-cargo-core-

- name: cache cargo `bench/tests` target
uses: actions/cache@v2
- uses: Swatinem/rust-cache@v2
with:
path: bench/tests/target
# Add date to the cache to keep it up to date
key: ubuntu-latest-nightly-cargo-benches-${{ hashFiles('bench/tests/Cargo.toml') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.platform }}-stable-cargo-benches-${{ hashFiles('bench/tests/Cargo.toml') }}
${{ matrix.platform }}-stable-cargo-benches-
workspaces: |
.
bench/tests

- name: run benchmarks
run: |
Expand Down
7 changes: 5 additions & 2 deletions bench/src/run_benchmark.rs
Expand Up @@ -64,7 +64,9 @@ fn run_strace_benchmarks(new_data: &mut utils::BenchResult) -> Result<()> {
file.as_file_mut().read_to_string(&mut output)?;

let strace_result = utils::parse_strace_output(&output);
let clone = strace_result.get("clone").map(|d| d.calls).unwrap_or(0) + 1;
let clone = 1
+ strace_result.get("clone").map(|d| d.calls).unwrap_or(0)
+ strace_result.get("clone3").map(|d| d.calls).unwrap_or(0);
let total = strace_result.get("total").unwrap().calls;
thread_count.insert(name.to_string(), clone);
syscall_count.insert(name.to_string(), total);
Expand Down Expand Up @@ -258,7 +260,8 @@ fn main() -> Result<()> {
let target_dir = utils::target_dir();
env::set_current_dir(&utils::bench_root_path())?;

let format = time::format_description::parse("[year]-[month]-[day]T[hour]:[minute]:[second]Z").unwrap();
let format =
time::format_description::parse("[year]-[month]-[day]T[hour]:[minute]:[second]Z").unwrap();
let now = time::OffsetDateTime::now_utc();

let mut new_data = utils::BenchResult {
Expand Down
35 changes: 25 additions & 10 deletions bench/src/utils.rs
Expand Up @@ -157,16 +157,31 @@ pub fn parse_strace_output(output: &str) -> HashMap<String, StraceOutput> {
}

let total_fields = total_line.split_whitespace().collect::<Vec<_>>();
summary.insert(
"total".to_string(),
StraceOutput {
percent_time: str::parse::<f64>(total_fields[0]).unwrap(),
seconds: str::parse::<f64>(total_fields[1]).unwrap(),
usecs_per_call: None,
calls: str::parse::<u64>(total_fields[2]).unwrap(),
errors: str::parse::<u64>(total_fields[3]).unwrap(),
},
);

match total_fields.len() {
// Old format, has no usecs/call
5 => summary.insert(
"total".to_string(),
StraceOutput {
percent_time: str::parse::<f64>(total_fields[0]).unwrap(),
seconds: str::parse::<f64>(total_fields[1]).unwrap(),
usecs_per_call: None,
calls: str::parse::<u64>(total_fields[2]).unwrap(),
errors: str::parse::<u64>(total_fields[3]).unwrap(),
},
),
6 => summary.insert(
"total".to_string(),
StraceOutput {
percent_time: str::parse::<f64>(total_fields[0]).unwrap(),
seconds: str::parse::<f64>(total_fields[1]).unwrap(),
usecs_per_call: Some(str::parse::<u64>(total_fields[2]).unwrap()),
calls: str::parse::<u64>(total_fields[3]).unwrap(),
errors: str::parse::<u64>(total_fields[4]).unwrap(),
},
),
_ => panic!("Unexpected total field count: {}", total_fields.len()),
};

summary
}
Expand Down