Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
dragoljub-duric committed Dec 14, 2023
2 parents f38bcda + 55cb05e commit 3ce5d00
Show file tree
Hide file tree
Showing 10 changed files with 310 additions and 209 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,42 @@ jobs:
- name: Run test
run: |
bash examples/test.sh
benchmark:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-1

- name: Install Rust
run: |
rustup update ${{ matrix.rust }} --no-self-update
rustup default ${{ matrix.rust }}
rustup target add wasm32-unknown-unknown
- name: Run benchmark test
run: |
bash benchmarks/benchmark_ci.sh
checks-pass:
# Always run this job!
if: always()
needs: [build, examples, benchmark]
runs-on: ubuntu-20.04
steps:
- name: check build result
if: ${{ needs.build.result != 'success' }}
run: exit 1
- name: check examples result
if: ${{ needs.examples.result != 'success' }}
run: exit 1
- name: check benchmark result
if: ${{ needs.benchmark.result != 'success' }}
run: exit 1
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ members = [
]

[workspace.dependencies]
candid = "0.9.5"
candid = "0.9.11"
ic-cdk = "0.10.0"
ic-cdk-macros = "0.7.1"
16 changes: 16 additions & 0 deletions benchmark-canisters/src/memory_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,19 @@ pub fn memory_manager_overhead() -> BenchResult {
}
})
}

/// Benchmarks the `MemoryManager`'s `grow` method.
#[ic_cdk_macros::query]
pub fn memory_manager_grow() -> BenchResult {
let mem_mgr = MemoryManager::init_with_bucket_size(DefaultMemoryImpl::default(), 1);

let buckets_per_memory = 32000;

let memory = mem_mgr.get(MemoryId::new(0));

crate::benchmark(|| {
for _ in 0..buckets_per_memory {
memory.grow(1);
}
})
}
1 change: 1 addition & 0 deletions benchmarks/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ lazy_static::lazy_static! {
// MemoryManager benchmarks
"memory_manager_baseline",
"memory_manager_overhead",
"memory_manager_grow",

// BTree benchmarks
"btreemap_insert_10mib_values",
Expand Down
16 changes: 16 additions & 0 deletions benchmarks/benchmark_ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -Eexuo pipefail

BENCH_OUTPUT=$(cargo bench)

set +e
REGRESSIONS=$( echo "$BENCH_OUTPUT" | grep -c "regressed by" )
set -e

if [[ $REGRESSIONS != 0 ]]; then
echo "FAIL! Performance regressions are detected.
Please run \"cargo bench -- --persist\" to update \"results.yml\""
exit 1
fi

echo "SUCCESS! Performance regressions are not detected."
Loading

0 comments on commit 3ce5d00

Please sign in to comment.