diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 1bbdb5633..ae6bedc47 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -6,12 +6,21 @@ 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 } @@ -19,10 +28,10 @@ jobs: 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 }} @@ -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: | diff --git a/bench/src/run_benchmark.rs b/bench/src/run_benchmark.rs index 32fc9de6f..77eae0201 100644 --- a/bench/src/run_benchmark.rs +++ b/bench/src/run_benchmark.rs @@ -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); diff --git a/bench/src/utils.rs b/bench/src/utils.rs index 969f67104..3e57fbe0f 100644 --- a/bench/src/utils.rs +++ b/bench/src/utils.rs @@ -157,16 +157,31 @@ pub fn parse_strace_output(output: &str) -> HashMap { } let total_fields = total_line.split_whitespace().collect::>(); - summary.insert( - "total".to_string(), - StraceOutput { - percent_time: str::parse::(total_fields[0]).unwrap(), - seconds: str::parse::(total_fields[1]).unwrap(), - usecs_per_call: None, - calls: str::parse::(total_fields[2]).unwrap(), - errors: str::parse::(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::(total_fields[0]).unwrap(), + seconds: str::parse::(total_fields[1]).unwrap(), + usecs_per_call: None, + calls: str::parse::(total_fields[2]).unwrap(), + errors: str::parse::(total_fields[3]).unwrap(), + }, + ), + 6 => summary.insert( + "total".to_string(), + StraceOutput { + percent_time: str::parse::(total_fields[0]).unwrap(), + seconds: str::parse::(total_fields[1]).unwrap(), + usecs_per_call: Some(str::parse::(total_fields[2]).unwrap()), + calls: str::parse::(total_fields[3]).unwrap(), + errors: str::parse::(total_fields[4]).unwrap(), + }, + ), + _ => panic!("Unexpected total field count: {}", total_fields.len()), + }; summary }