From c3edd1d344aa7c90539a54f713bd4090c1df5970 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 07:23:07 -0500 Subject: [PATCH 1/4] chore(deps): bump candid from 0.9.5 to 0.9.11 (#158) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [candid](https://github.com/dfinity/candid) from 0.9.5 to 0.9.11.
Changelog

Sourced from candid's changelog.

Rust 0.9.9 -- 0.9.11

2023-09-27

Rust 0.9.8

Candid UI

Rust 0.9.7

2023-09-05 (Rust 0.9.6)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=candid&package-manager=cargo&previous-version=0.9.5&new-version=0.9.11)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/dfinity/stable-structures/network/alerts).
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 973c1dcf..d751846b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -143,9 +143,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "candid" -version = "0.9.5" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "762aa04e3a889d47a1773b74ee3b13438a9bc895954fff79ebf7f308c3744a6c" +checksum = "465c1ce01d8089ee5b49ba20d3a9da15a28bba64c35cdff2aa256d37e319625d" dependencies = [ "anyhow", "binread", @@ -170,9 +170,9 @@ dependencies = [ [[package]] name = "candid_derive" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "810b3bd60244f282090652ffc7c30a9d23892e72dfe443e46ee55569044f7dd5" +checksum = "201ea498d901add0822653ac94cb0f8a92f9b1758a5273f4dafbb6673c9a5020" dependencies = [ "lazy_static", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index ef0ee3c1..316414f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,6 +46,6 @@ members = [ ] [workspace.dependencies] -candid = "0.9.5" +candid = "0.9.11" ic-cdk = "0.10.0" ic-cdk-macros = "0.7.1" From 335424da737955419fd9e95e04113bb799e0b7c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 12:25:53 +0000 Subject: [PATCH 2/4] chore(deps): bump candid from 0.9.5 to 0.9.11 in /examples (#159) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [candid](https://github.com/dfinity/candid) from 0.9.5 to 0.9.11.
Changelog

Sourced from candid's changelog.

Rust 0.9.9 -- 0.9.11

  • Set different config values for full_error_message and zero_sized_values for Wasm and non-Wasm target.
  • Fix subtyping error message for empty type.
  • Remove name duplication check in candid_method to avoid errors on certain IDEs.
  • Improvements in Candid UI
    • Add II button, thanks to @​Web3NL.
    • Support streaming download of profiling data.

2023-09-27

Rust 0.9.8

  • Implement CandidType for std::cmp::Reverse.
  • Rust codegen: add pub for struct fields.
  • Fix merge_init_types and instantiate_candid when the main actor refers to a variable.

Candid UI

  • Draw flamegraph for canister upgrade
  • Upstream fix from merge_init_types

Rust 0.9.7

  • Add utils::merge_init_args to parse and merge candid:args metadata, and add the same endpoint in Candid UI.
  • Add record! and variant! macro to generate record and variant type AST.
  • Allow trailing comma in func! macro.
  • Add minize_error_message to IDLDeserialize::Config.

2023-09-05 (Rust 0.9.6)

  • Improve Rust binding generation: 1) Fix generated code for agent; 2) Generated names conform to Rust convention: Pascal case for type names and enum tags; snake case for function names.
  • Fix a bug when deriving empty struct/tuple enum tag, e.g., #[derive(CandidType)] enum T { A{}, B() }.
  • Add IDLDeserialize::new_with_config to control deserializer behavior. For now, you can only bound the size of zero sized values.
Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=candid&package-manager=cargo&previous-version=0.9.5&new-version=0.9.11)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/dfinity/stable-structures/network/alerts).
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Islam El-Ashi --- examples/Cargo.lock | 8 ++++---- examples/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/Cargo.lock b/examples/Cargo.lock index 0a4a02fb..145f8d22 100644 --- a/examples/Cargo.lock +++ b/examples/Cargo.lock @@ -81,9 +81,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "candid" -version = "0.9.5" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "762aa04e3a889d47a1773b74ee3b13438a9bc895954fff79ebf7f308c3744a6c" +checksum = "465c1ce01d8089ee5b49ba20d3a9da15a28bba64c35cdff2aa256d37e319625d" dependencies = [ "anyhow", "binread", @@ -108,9 +108,9 @@ dependencies = [ [[package]] name = "candid_derive" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "810b3bd60244f282090652ffc7c30a9d23892e72dfe443e46ee55569044f7dd5" +checksum = "201ea498d901add0822653ac94cb0f8a92f9b1758a5273f4dafbb6673c9a5020" dependencies = [ "lazy_static", "proc-macro2", diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 86df5131..2c2cd57f 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -9,6 +9,6 @@ members = [ ] [workspace.dependencies] -candid = "0.9.5" +candid = "0.9.11" ic-cdk = "0.10.0" ic-cdk-macros = "0.7.1" From 0ea56816edcebddc2e5ac5938275612cb5a53c69 Mon Sep 17 00:00:00 2001 From: Dragoljub Djuric Date: Wed, 13 Dec 2023 19:10:23 +0100 Subject: [PATCH 3/4] feat: Add benchmark to StableStructures CI (#160) After that add a benchmark to StableStructures CI to ensure that we do not introduce performance regressions. Add a benchmark where we allocate a large number of buckets and see how this current PR affects the performance of that benchmark. --- .github/workflows/ci.yml | 39 ++++ benchmarks/benchmark_ci.sh | 16 ++ benchmarks/results.yml | 390 ++++++++++++++++++------------------ benchmarks/run-benchmark.sh | 37 +++- 4 files changed, 283 insertions(+), 199 deletions(-) create mode 100755 benchmarks/benchmark_ci.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a4a43628..f2e9744d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 \ No newline at end of file diff --git a/benchmarks/benchmark_ci.sh b/benchmarks/benchmark_ci.sh new file mode 100755 index 00000000..7f0823a0 --- /dev/null +++ b/benchmarks/benchmark_ci.sh @@ -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." diff --git a/benchmarks/results.yml b/benchmarks/results.yml index d8957edf..6e03bf38 100644 --- a/benchmarks/results.yml +++ b/benchmarks/results.yml @@ -1,436 +1,440 @@ btreemap_get_blob_128_1024: measurements: - instructions: 1036492848 - node_load_v1: 841594727 + instructions: 1006573538 + node_load_v1: 832328557 stable_memory_size: 261 btreemap_get_blob_128_1024_v2: measurements: - instructions: 1141645046 - node_load_v2: 934916254 + instructions: 1123805990 + node_load_v2: 938155476 stable_memory_size: 196 btreemap_get_blob_16_1024: measurements: - instructions: 554418274 - node_load_v1: 385854486 + instructions: 487229806 + node_load_v1: 339804418 stable_memory_size: 216 btreemap_get_blob_16_1024_v2: measurements: - instructions: 638707284 - node_load_v2: 465108651 + instructions: 583474971 + node_load_v2: 430852270 stable_memory_size: 162 btreemap_get_blob_256_1024: measurements: - instructions: 1524044018 - node_load_v1: 1303981210 + instructions: 1510660940 + node_load_v1: 1309093774 stable_memory_size: 293 btreemap_get_blob_256_1024_v2: measurements: - instructions: 1629850230 - node_load_v2: 1394151407 + instructions: 1626341678 + node_load_v2: 1410845462 stable_memory_size: 220 btreemap_get_blob_32_1024: measurements: - instructions: 592168259 - node_load_v1: 412494322 + instructions: 534895222 + node_load_v1: 378516147 stable_memory_size: 231 btreemap_get_blob_32_1024_v2: measurements: - instructions: 681076638 - node_load_v2: 496647939 + instructions: 633048491 + node_load_v2: 471574348 stable_memory_size: 174 btreemap_get_blob_4_1024: measurements: - instructions: 404326079 - node_load_v1: 263154177 + instructions: 355650535 + node_load_v1: 231720942 stable_memory_size: 124 btreemap_get_blob_4_1024_v2: measurements: - instructions: 482401308 - node_load_v2: 331326661 + instructions: 446660432 + node_load_v2: 313869359 stable_memory_size: 93 btreemap_get_blob_512_1024: measurements: - instructions: 2489665479 - node_load_v1: 2221220570 + instructions: 2506597898 + node_load_v1: 2251570705 stable_memory_size: 352 btreemap_get_blob_512_1024_v2: measurements: - instructions: 2597665998 - node_load_v2: 2313508444 + instructions: 2625838052 + node_load_v2: 2356816367 stable_memory_size: 264 btreemap_get_blob_64_1024: measurements: - instructions: 815072508 - node_load_v1: 629854103 + instructions: 780061526 + node_load_v1: 616669297 stable_memory_size: 246 btreemap_get_blob_64_1024_v2: measurements: - instructions: 904428083 - node_load_v2: 709898451 + instructions: 878745163 + node_load_v2: 706540951 stable_memory_size: 184 btreemap_get_blob_8_1024: measurements: - instructions: 473946591 - node_load_v1: 306139149 + instructions: 406432578 + node_load_v1: 259168629 stable_memory_size: 184 btreemap_get_blob_8_1024_v2: measurements: - instructions: 550538004 - node_load_v2: 372248435 + instructions: 493282925 + node_load_v2: 336415667 stable_memory_size: 139 btreemap_get_blob_8_u64: measurements: - instructions: 426573085 - node_load_v1: 296477748 + instructions: 368106593 + node_load_v1: 253569163 stable_memory_size: 7 btreemap_get_blob_8_u64_v2: measurements: - instructions: 524539438 - node_load_v2: 383993056 + instructions: 466009078 + node_load_v2: 345475118 stable_memory_size: 5 btreemap_get_u64_blob_8: measurements: - instructions: 408377288 - node_load_v1: 292507322 + instructions: 351156467 + node_load_v1: 250986516 stable_memory_size: 8 btreemap_get_u64_blob_8_v2: measurements: - instructions: 477717380 - node_load_v2: 354588536 + instructions: 413554294 + node_load_v2: 309705639 stable_memory_size: 6 btreemap_get_u64_u64: measurements: - instructions: 411553460 - node_load_v1: 291036337 + instructions: 353621464 + node_load_v1: 249502481 stable_memory_size: 8 btreemap_get_u64_u64_v2: measurements: - instructions: 489803504 - node_load_v2: 359046114 + instructions: 422146359 + node_load_v2: 312364993 stable_memory_size: 7 btreemap_insert_10mib_values: measurements: - instructions: 153916996 - node_load_v2: 10524604 - node_save_v2: 121610529 + instructions: 107942355 + node_load_v2: 10057317 + node_save_v2: 77823608 stable_memory_size: 33 btreemap_insert_blob_128_1024: measurements: - instructions: 1728083375 - node_load_v1: 820967230 - node_save_v1: 424336331 + instructions: 1577091213 + node_load_v1: 812526962 + node_save_v1: 301462572 stable_memory_size: 261 btreemap_insert_blob_128_1024_v2: measurements: - instructions: 1887438503 - node_load_v2: 917898123 - node_save_v2: 473030261 + instructions: 1726441521 + node_load_v2: 925130424 + node_save_v2: 322015815 stable_memory_size: 196 btreemap_insert_blob_16_1024: measurements: - instructions: 1175284821 - node_load_v1: 364931829 - node_save_v1: 403232566 + instructions: 992366717 + node_load_v1: 322073344 + node_save_v1: 291094888 stable_memory_size: 216 btreemap_insert_blob_16_1024_v2: measurements: - instructions: 1297189840 - node_load_v2: 441604445 - node_save_v2: 450799265 + instructions: 1108674244 + node_load_v2: 419541518 + node_save_v2: 310638874 stable_memory_size: 162 btreemap_insert_blob_256_1024: measurements: - instructions: 2253581857 - node_load_v1: 1274264944 - node_save_v1: 429936500 + instructions: 2114284649 + node_load_v1: 1278881721 + node_save_v1: 300728644 stable_memory_size: 293 btreemap_insert_blob_256_1024_v2: measurements: - instructions: 2418048329 - node_load_v2: 1370054185 - node_save_v2: 478611131 + instructions: 2273386999 + node_load_v2: 1395147359 + node_save_v2: 321544817 stable_memory_size: 220 btreemap_insert_blob_32_1024: measurements: - instructions: 1222438436 - node_load_v1: 392818595 - node_save_v1: 415591575 + instructions: 1041724177 + node_load_v1: 358626551 + node_save_v1: 298295476 stable_memory_size: 231 btreemap_insert_blob_32_1024_v2: measurements: - instructions: 1347651855 - node_load_v2: 478839969 - node_save_v2: 463457239 + instructions: 1156895178 + node_load_v2: 459271136 + node_save_v2: 316798162 stable_memory_size: 174 btreemap_insert_blob_4_1024: measurements: - instructions: 938801513 - node_load_v1: 249902009 - node_save_v1: 369888833 + instructions: 772106359 + node_load_v1: 212848724 + node_save_v1: 267119730 stable_memory_size: 124 btreemap_insert_blob_4_1024_v2: measurements: - instructions: 1034858980 - node_load_v2: 303990014 - node_save_v2: 412472844 + instructions: 862904908 + node_load_v2: 286322995 + node_save_v2: 284380143 stable_memory_size: 93 btreemap_insert_blob_512_1024: measurements: - instructions: 3304579238 - node_load_v1: 2164221161 - node_save_v1: 447224687 + instructions: 3195541992 + node_load_v1: 2200910325 + node_save_v1: 306828402 stable_memory_size: 352 btreemap_insert_blob_512_1024_v2: measurements: - instructions: 3441055298 - node_load_v2: 2251075024 - node_save_v2: 495817725 + instructions: 3317431106 + node_load_v2: 2302979370 + node_save_v2: 323365428 stable_memory_size: 264 btreemap_insert_blob_64_1024: measurements: - instructions: 1461955565 - node_load_v1: 598055576 - node_save_v1: 418506217 + instructions: 1305958991 + node_load_v1: 584672643 + node_save_v1: 300400388 stable_memory_size: 246 btreemap_insert_blob_64_1024_v2: measurements: - instructions: 1608231357 - node_load_v2: 693480323 - node_save_v2: 466915682 + instructions: 1439210453 + node_load_v2: 692993072 + node_save_v2: 319569550 stable_memory_size: 184 btreemap_insert_blob_8_1024: measurements: - instructions: 1082429287 - node_load_v1: 288373408 - node_save_v1: 394091363 + instructions: 905706875 + node_load_v1: 247335003 + node_save_v1: 284445265 stable_memory_size: 184 btreemap_insert_blob_8_1024_v2: measurements: - instructions: 1185459001 - node_load_v2: 346301469 - node_save_v2: 440144216 + instructions: 1002633716 + node_load_v2: 325787553 + node_save_v2: 303101882 stable_memory_size: 139 btreemap_insert_blob_8_u64: measurements: - instructions: 678191751 - node_load_v1: 281156599 - node_save_v1: 186568536 + instructions: 589493749 + node_load_v1: 243685209 + node_save_v1: 164111004 stable_memory_size: 7 btreemap_insert_blob_8_u64_v2: measurements: - instructions: 796895423 - node_load_v2: 348902427 - node_save_v2: 237301444 + instructions: 697133799 + node_load_v2: 329438301 + node_save_v2: 184403609 stable_memory_size: 5 btreemap_insert_u64_blob_8: measurements: - instructions: 740393452 - node_load_v1: 276721774 - node_save_v1: 256838739 + instructions: 611656296 + node_load_v1: 233854938 + node_save_v1: 203753854 stable_memory_size: 8 btreemap_insert_u64_blob_8_v2: measurements: - instructions: 832660221 - node_load_v2: 332110696 - node_save_v2: 296065090 + instructions: 679823522 + node_load_v2: 294338080 + node_save_v2: 211575679 stable_memory_size: 6 btreemap_insert_u64_u64: measurements: - instructions: 756415522 - node_load_v1: 271685362 - node_save_v1: 266589945 + instructions: 627664728 + node_load_v1: 234409394 + node_save_v1: 211208718 stable_memory_size: 8 btreemap_insert_u64_u64_v2: measurements: - instructions: 854388312 - node_load_v2: 332160444 - node_save_v2: 305568940 + instructions: 703623870 + node_load_v2: 300411584 + node_save_v2: 220348622 stable_memory_size: 7 btreemap_remove_blob_128_1024: measurements: - instructions: 2234896023 - node_load_v1: 925140798 - node_save_v1: 716437888 + instructions: 1957356649 + node_load_v1: 914434789 + node_save_v1: 514074570 stable_memory_size: 261 btreemap_remove_blob_128_1024_v2: measurements: - instructions: 2438262123 - node_load_v2: 1030690836 - node_save_v2: 817765611 + instructions: 2117203127 + node_load_v2: 1032337866 + node_save_v2: 556162319 stable_memory_size: 196 btreemap_remove_blob_16_1024: measurements: - instructions: 1543425658 - node_load_v1: 422708266 - node_save_v1: 653989748 + instructions: 1247951670 + node_load_v1: 371456037 + node_save_v1: 473518008 stable_memory_size: 216 btreemap_remove_blob_16_1024_v2: measurements: - instructions: 1722829420 - node_load_v2: 515941729 - node_save_v2: 746529796 + instructions: 1391842517 + node_load_v2: 479235617 + node_save_v2: 512046945 stable_memory_size: 162 btreemap_remove_blob_256_1024: measurements: - instructions: 2837558812 - node_load_v1: 1424257338 - node_save_v1: 722240539 + instructions: 2573453911 + node_load_v1: 1428465620 + node_save_v1: 511120662 stable_memory_size: 293 btreemap_remove_blob_256_1024_v2: measurements: - instructions: 3043582992 - node_load_v2: 1529753149 - node_save_v2: 820959509 + instructions: 2738027594 + node_load_v2: 1548255619 + node_save_v2: 551257725 stable_memory_size: 220 btreemap_remove_blob_32_1024: measurements: - instructions: 1621204146 - node_load_v1: 446089231 - node_save_v1: 680680401 + instructions: 1324817959 + node_load_v1: 403513191 + node_save_v1: 492234126 stable_memory_size: 231 btreemap_remove_blob_32_1024_v2: measurements: - instructions: 1809708985 - node_load_v2: 547069086 - node_save_v2: 777087499 + instructions: 1476050369 + node_load_v2: 519013227 + node_save_v2: 532132813 stable_memory_size: 174 btreemap_remove_blob_4_1024: measurements: - instructions: 1007752822 - node_load_v1: 273336525 - node_save_v1: 420883123 + instructions: 807721649 + node_load_v1: 233144442 + node_save_v1: 306452731 stable_memory_size: 124 btreemap_remove_blob_4_1024_v2: measurements: - instructions: 1126985969 - node_load_v2: 335787632 - node_save_v2: 479866306 + instructions: 913517563 + node_load_v2: 314086802 + node_save_v2: 331046095 stable_memory_size: 93 btreemap_remove_blob_512_1024: measurements: - instructions: 4122610417 - node_load_v1: 2444088137 - node_save_v1: 764541981 + instructions: 3867652464 + node_load_v1: 2474030645 + node_save_v1: 527547819 stable_memory_size: 352 btreemap_remove_blob_512_1024_v2: measurements: - instructions: 4336724956 - node_load_v2: 2552639967 - node_save_v2: 867403999 + instructions: 4041285449 + node_load_v2: 2600718246 + node_save_v2: 569534896 stable_memory_size: 264 btreemap_remove_blob_64_1024: measurements: - instructions: 1915399650 - node_load_v1: 677968350 - node_save_v1: 699843250 + instructions: 1639040548 + node_load_v1: 661396112 + node_save_v1: 505335855 stable_memory_size: 246 btreemap_remove_blob_64_1024_v2: measurements: - instructions: 2115847476 - node_load_v2: 784399427 - node_save_v2: 798997235 + instructions: 1795315618 + node_load_v2: 778335609 + node_save_v2: 546167574 stable_memory_size: 184 btreemap_remove_blob_8_1024: measurements: - instructions: 1298743070 - node_load_v1: 328080817 - node_save_v1: 561793980 + instructions: 1038596601 + node_load_v1: 278756927 + node_save_v1: 408063372 stable_memory_size: 184 btreemap_remove_blob_8_1024_v2: measurements: - instructions: 1438952709 - node_load_v2: 393090231 - node_save_v2: 641773986 + instructions: 1150784585 + node_load_v2: 359148126 + node_save_v2: 441289916 stable_memory_size: 139 btreemap_remove_blob_8_u64: measurements: - instructions: 902063103 - node_load_v1: 320925615 - node_save_v1: 301798231 + instructions: 756190189 + node_load_v1: 271109869 + node_save_v1: 258955340 stable_memory_size: 7 btreemap_remove_blob_8_u64_v2: measurements: - instructions: 1086883574 - node_load_v2: 408809674 - node_save_v2: 393123341 + instructions: 902070967 + node_load_v2: 371425008 + node_save_v2: 300237913 stable_memory_size: 5 btreemap_remove_u64_blob_8: measurements: - instructions: 1073130645 - node_load_v1: 314124252 - node_save_v1: 459748260 + instructions: 846321611 + node_load_v1: 263317086 + node_save_v1: 354096302 stable_memory_size: 8 btreemap_remove_u64_blob_8_v2: measurements: - instructions: 1218013583 - node_load_v2: 379454454 - node_save_v2: 533196738 + instructions: 935942012 + node_load_v2: 329460173 + node_save_v2: 373120565 stable_memory_size: 6 btreemap_remove_u64_u64: measurements: - instructions: 1110523046 - node_load_v1: 314495794 - node_save_v1: 485183169 + instructions: 874256488 + node_load_v1: 264707458 + node_save_v1: 370018389 stable_memory_size: 8 btreemap_remove_u64_u64_v2: measurements: - instructions: 1271869109 - node_load_v2: 387460876 - node_save_v2: 566512955 + instructions: 976419924 + node_load_v2: 337138522 + node_save_v2: 394608862 stable_memory_size: 7 memory_manager_baseline: measurements: - instructions: 1176576551 + instructions: 1144 stable_memory_size: 8000 +memory_manager_buckets_allocation: + measurements: + instructions: 9043414 + stable_memory_size: 128001 memory_manager_overhead: measurements: - instructions: 1182012269 + instructions: 4605248 stable_memory_size: 8321 vec_get_blob_128: measurements: - instructions: 25331980 + instructions: 22055455 stable_memory_size: 20 vec_get_blob_16: measurements: - instructions: 14914959 + instructions: 11055138 stable_memory_size: 3 vec_get_blob_32: measurements: - instructions: 15584015 + instructions: 11849080 stable_memory_size: 6 vec_get_blob_4: measurements: - instructions: 10027133 + instructions: 6830239 stable_memory_size: 1 vec_get_blob_8: measurements: - instructions: 11988806 + instructions: 8222880 stable_memory_size: 2 vec_get_u64: measurements: - instructions: 11540290 + instructions: 7450346 stable_memory_size: 2 vec_insert_blob_128: measurements: - instructions: 6109513 + instructions: 4942837 stable_memory_size: 20 vec_insert_blob_16: measurements: - instructions: 5186050 + instructions: 4880610 stable_memory_size: 3 vec_insert_blob_32: measurements: - instructions: 5394984 + instructions: 4941003 stable_memory_size: 6 vec_insert_blob_4: measurements: - instructions: 5187495 + instructions: 4940348 stable_memory_size: 1 vec_insert_blob_8: measurements: - instructions: 5216814 + instructions: 4940479 stable_memory_size: 2 vec_insert_u64: measurements: - instructions: 12149357 + instructions: 7600479 stable_memory_size: 2 diff --git a/benchmarks/run-benchmark.sh b/benchmarks/run-benchmark.sh index 0a0f0d49..8fffe495 100755 --- a/benchmarks/run-benchmark.sh +++ b/benchmarks/run-benchmark.sh @@ -6,18 +6,43 @@ set -euo pipefail BENCH_NAME=$1 FILE=$(mktemp) -if ! type "drun" > /dev/null; then - echo "drun is not installed. Please add drun to your path from commit d35535c96184be039aaa31f68b48bbe45909494e." - exit 1 -fi +DRUN_LINUX_SHA="7bf08d5f1c1a7cd44f62c03f8554f07aa2430eb3ae81c7c0a143a68ff52dc7f7" +DRUN_MAC_SHA="57b506d05a6f42f7461198f79f648ad05434c72f3904834db2ced30853d01a62" +DRUN_RELEASE_URL_PREFIX="https://github.com/dfinity/ic/releases/download/release-2023-09-27_23-01%2Bquic/drun-x86_64-" -cat > $FILE << EOF +download_drun(){ + OS=$1 + wget -O "drun.gz" "${DRUN_RELEASE_URL_PREFIX}${OS}.gz" + gzip -fd drun.gz + chmod +x drun +} + +get_correct_drun_release() { + OS=$(uname | tr '[:upper:]' '[:lower:]') + + # Check if drun exists in the current repository. + if ! [ -e "drun" ]; then + download_drun "$OS" + else + DRUN_SHA=$(shasum -a 256 "drun" | awk '{ print $1 }') + # Check if drun exists and if the correct version is used. + if ! [[ "$OS" == "linux" && "$DRUN_SHA" == "$DRUN_LINUX_SHA" ]]; then + if ! [[ "$OS" == "darwin" && "$DRUN_SHA" == "$DRUN_MAC_SHA" ]]; then + download_drun "$OS" + fi + fi + fi +} + +get_correct_drun_release + +cat > "$FILE" << EOF create install rwlgt-iiaaa-aaaaa-aaaaa-cai ../target/wasm32-unknown-unknown/release/benchmarks.wasm "" query rwlgt-iiaaa-aaaaa-aaaaa-cai ${BENCH_NAME} "DIDL\x00\x00" EOF # Run the benchmarks, decode the output. -drun $FILE --instruction-limit 99999999999999 \ +./drun $FILE --instruction-limit 99999999999999 \ | awk '{ print $3 }' \ | grep "44.*" -o From 55cb05e9ef908f43c7b9e8f33c55cb3d9d1dfc98 Mon Sep 17 00:00:00 2001 From: Dragoljub Djuric Date: Thu, 14 Dec 2023 17:47:41 +0100 Subject: [PATCH 4/4] perf: Add benchmark test with allocation of many buckets to StableStructures (#164) Co-authored-by: Islam El-Ashi --- benchmark-canisters/src/memory_manager.rs | 16 ++++++++++++++++ benchmarks/benchmark.rs | 1 + benchmarks/results.yml | 6 +++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/benchmark-canisters/src/memory_manager.rs b/benchmark-canisters/src/memory_manager.rs index 383ba7f8..22f95257 100644 --- a/benchmark-canisters/src/memory_manager.rs +++ b/benchmark-canisters/src/memory_manager.rs @@ -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); + } + }) +} diff --git a/benchmarks/benchmark.rs b/benchmarks/benchmark.rs index 4b22127d..e901e4c0 100644 --- a/benchmarks/benchmark.rs +++ b/benchmarks/benchmark.rs @@ -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", diff --git a/benchmarks/results.yml b/benchmarks/results.yml index 6e03bf38..288304b4 100644 --- a/benchmarks/results.yml +++ b/benchmarks/results.yml @@ -382,10 +382,10 @@ memory_manager_baseline: measurements: instructions: 1144 stable_memory_size: 8000 -memory_manager_buckets_allocation: +memory_manager_grow: measurements: - instructions: 9043414 - stable_memory_size: 128001 + instructions: 287018881 + stable_memory_size: 32001 memory_manager_overhead: measurements: instructions: 4605248