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

feat: add basic profiling to benchmarks #116

Merged
merged 11 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from 8 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
- name: Install DFX
run: |
wget --output-document install-dfx.sh "https://internetcomputer.org/install.sh"
DFX_VERSION=${DFX_VERSION:=0.14.1} bash install-dfx.sh < <(yes Y)
DFX_VERSION=${DFX_VERSION:=0.14.3} bash install-dfx.sh < <(yes Y)
rm install-dfx.sh
dfx cache install
echo "$HOME/bin" >> $GITHUB_PATH
Expand Down
9 changes: 9 additions & 0 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ keywords = ["internet-computer", "dfinity", "stable-structures"]
include = ["src", "Cargo.toml", "LICENSE", "README.md"]
repository = "https://github.com/dfinity/stable-structures"

[dependencies]
# An optional dependency to profile parts of the code.
profiler = { path = "./profiler", optional = true }

[dev-dependencies]
criterion = "0.4.0"
ic-cdk = "0.6.8"
Expand Down
37 changes: 37 additions & 0 deletions benches/benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ fn execution_instructions(arguments: ExecutionArguments) -> u64 {
let stderr = String::from_utf8(output.stderr).unwrap();
assert!(output.status.success(), "{stdout}\n{stderr}");

// Output logs from the canister as it contains profiling data.
println!();
println!("{stderr}");

// Convert result formatted as "(1_000_000 : nat64)" to u64.
let result = stdout
.trim()
Expand Down Expand Up @@ -177,40 +181,73 @@ pub fn criterion_benchmark(c: &mut Criterion<Instructions>) {

// BTree benchmarks
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_blob_4_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_blob_4_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_blob_8_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_blob_8_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_blob_16_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_blob_16_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_blob_32_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_blob_32_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_blob_64_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_blob_64_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_blob_128_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_blob_128_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_blob_256_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_blob_256_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_blob_512_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_blob_512_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_u64_u64");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_u64_u64_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_u64_blob_8");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_u64_blob_8_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_blob_8_u64");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_insert_blob_8_u64_v2");

bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_blob_4_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_blob_4_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_blob_8_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_blob_8_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_blob_16_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_blob_16_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_blob_32_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_blob_32_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_blob_64_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_blob_64_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_blob_128_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_blob_128_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_u64_u64");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_u64_u64_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_u64_blob_8");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_u64_blob_8_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_blob_8_u64");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_blob_8_u64_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_blob_256_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_blob_256_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_blob_512_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_get_blob_512_1024_v2");

bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_blob_4_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_blob_4_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_blob_8_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_blob_8_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_blob_16_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_blob_16_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_blob_32_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_blob_32_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_blob_64_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_blob_64_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_blob_128_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_blob_128_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_blob_256_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_blob_256_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_blob_512_1024");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_blob_512_1024_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_u64_u64");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_u64_u64_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_u64_blob_8");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_u64_blob_8_v2");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_blob_8_u64");
bench_function(c, *BENCHMARK_CANISTER, "btreemap_remove_blob_8_u64_v2");

// Vec benchmarks
bench_function(c, *BENCHMARK_CANISTER, "vec_insert_blob_4");
Expand Down
2 changes: 1 addition & 1 deletion benches/run-benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
set -euo pipefail

BENCH_NAME=$1
FILE=mktemp
FILE=$(mktemp)

if ! type "drun" > /dev/null; then
echo "drun is not installed. Please add drun to your path from commit d35535c96184be039aaa31f68b48bbe45909494e."
Expand Down
3 changes: 2 additions & 1 deletion benchmark-canisters/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ edition = "2021"
[dependencies]
ic-cdk = "0.6.8"
ic-cdk-macros = "0.6.8"
ic-stable-structures = { path = "../" }
ic-stable-structures = { path = "../", features = ["profiler"] }
profiler = { path = "../profiler" }
tiny-rng = "0.2.0"
4 changes: 2 additions & 2 deletions benchmark-canisters/dfx.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dfx": "0.12.1",
"dfx": "0.14.3",
"canisters": {
"benchmarks": {
"candid": "candid.did",
Expand All @@ -16,4 +16,4 @@
}
},
"version": 1
}
}
Loading
Loading