From 494055d171828a7d38edc03de9a853e8b577e8d5 Mon Sep 17 00:00:00 2001 From: Robin van Boven <497556+Beanow@users.noreply.github.com> Date: Fri, 9 Dec 2022 20:56:44 +0100 Subject: [PATCH 1/8] fix(bench): Include clone3 in thread count It's a newer syscall interface and gets counted seperately in strace results. --- bench/src/run_benchmark.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bench/src/run_benchmark.rs b/bench/src/run_benchmark.rs index 10bb14117..dbff9ab95 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); From f1d53cf65e75f661f9dbccf58c5283e3a11f3347 Mon Sep 17 00:00:00 2001 From: Beanow <497556+Beanow@users.noreply.github.com> Date: Fri, 9 Dec 2022 20:57:45 +0100 Subject: [PATCH 2/8] fix(bench): Update totals line parsing The column offsets didn't match up when usecs/call is included in the totals. --- bench/src/utils.rs | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/bench/src/utils.rs b/bench/src/utils.rs index 82414802f..34ca31c36 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 } From 297982408409f54cf63ff6bf42d0c718e4d8484a Mon Sep 17 00:00:00 2001 From: Beanow <497556+Beanow@users.noreply.github.com> Date: Fri, 9 Dec 2022 21:02:01 +0100 Subject: [PATCH 3/8] fix(bench): Enforce locale, avoiding parse errors On my local machine, it used an NL locale changing the strace numbers to use commas. Adding this env var avoids that problem. --- .github/workflows/bench.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 1bbdb5633..0e3f4d4c8 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -6,6 +6,9 @@ on: - dev workflow_dispatch: +env: + LC_ALL: en_US.UTF-8 # This prevents strace from changing it's number format to use commas. + jobs: bench: strategy: From 8f38e7a153513a91ea5734b2424538dc62a4c009 Mon Sep 17 00:00:00 2001 From: Beanow <497556+Beanow@users.noreply.github.com> Date: Fri, 9 Dec 2022 21:02:48 +0100 Subject: [PATCH 4/8] fix(bench): Use matrix for the rust toolchain version --- .github/workflows/bench.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 0e3f4d4c8..8f4b313f6 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - rust_version: [stable] + rust: [nightly] platform: - { target: x86_64-unknown-linux-gnu, os: ubuntu-latest } @@ -22,10 +22,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 }} From 8fb58df339a0918d4ffa59d380584ed98ab959b5 Mon Sep 17 00:00:00 2001 From: Beanow <497556+Beanow@users.noreply.github.com> Date: Fri, 9 Dec 2022 21:03:57 +0100 Subject: [PATCH 5/8] fix(bench): Avoid multiple runs --- .github/workflows/bench.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 8f4b313f6..e8735bedd 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -9,6 +9,10 @@ on: env: 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: From 6165aac22178d869d355bdbb4e5602a8fc5ba659 Mon Sep 17 00:00:00 2001 From: Beanow <497556+Beanow@users.noreply.github.com> Date: Fri, 9 Dec 2022 21:04:17 +0100 Subject: [PATCH 6/8] fix(bench): Ensure backtraces --- .github/workflows/bench.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index e8735bedd..1dcbab682 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -7,6 +7,7 @@ on: workflow_dispatch: env: + RUST_BACKTRACE: 1 LC_ALL: en_US.UTF-8 # This prevents strace from changing it's number format to use commas. concurrency: From 558f33a1187535680707328f6c2f0bcbca1b71a6 Mon Sep 17 00:00:00 2001 From: Beanow <497556+Beanow@users.noreply.github.com> Date: Fri, 9 Dec 2022 21:06:36 +0100 Subject: [PATCH 7/8] fix(bench): Simplify caching similar to tauri --- .github/workflows/bench.yml | 50 ++++--------------------------------- 1 file changed, 5 insertions(+), 45 deletions(-) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 1dcbab682..ae6bedc47 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -8,6 +8,7 @@ on: 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: @@ -50,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: | From 7969feebc1c3bf14e5013ff0ae7554ef29786df6 Mon Sep 17 00:00:00 2001 From: Beanow <497556+Beanow@users.noreply.github.com> Date: Fri, 9 Dec 2022 21:06:57 +0100 Subject: [PATCH 8/8] fix(bench): Linter change --- bench/src/run_benchmark.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bench/src/run_benchmark.rs b/bench/src/run_benchmark.rs index dbff9ab95..294078f25 100644 --- a/bench/src/run_benchmark.rs +++ b/bench/src/run_benchmark.rs @@ -260,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 {