From 0071d15aed87f051aa3d1e444adccc69c2e9bed7 Mon Sep 17 00:00:00 2001 From: Claudio Russo Date: Thu, 5 Oct 2023 04:18:26 +0100 Subject: [PATCH 01/10] target branch claudio --- collections/motoko/mops.template.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collections/motoko/mops.template.toml b/collections/motoko/mops.template.toml index c626235e..192a1087 100644 --- a/collections/motoko/mops.template.toml +++ b/collections/motoko/mops.template.toml @@ -4,4 +4,4 @@ stableheapbtreemap = "1.3.0" map = "9.0.0" splay = "0.1.0" vector = "0.2.0" -StableBTree = "https://github.com/crusso/MotokoStableBTree" +StableBTree = "https://github.com/crusso/MotokoStableBTree/tree/claudio" From 1e911af2436d52f83dc2faae515b519240f6b054 Mon Sep 17 00:00:00 2001 From: Claudio Russo Date: Thu, 5 Oct 2023 23:39:40 +0100 Subject: [PATCH 02/10] try something new --- collections/motoko/mops.template.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collections/motoko/mops.template.toml b/collections/motoko/mops.template.toml index 192a1087..7ce62753 100644 --- a/collections/motoko/mops.template.toml +++ b/collections/motoko/mops.template.toml @@ -1,5 +1,5 @@ [dependencies] -base = "https://github.com/dfinity/motoko-base#moc-$MOC_VERSION" +base = "$MOC_VERSION" stableheapbtreemap = "1.3.0" map = "9.0.0" splay = "0.1.0" From d9235de2710d5079b687d4a9e61bbb5046d081ba Mon Sep 17 00:00:00 2001 From: Claudio Russo Date: Thu, 5 Oct 2023 23:49:52 +0100 Subject: [PATCH 03/10] hackity hack --- collections/motoko/src/btreemap_stable.mo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/collections/motoko/src/btreemap_stable.mo b/collections/motoko/src/btreemap_stable.mo index 6cc8fa53..33ae2e11 100644 --- a/collections/motoko/src/btreemap_stable.mo +++ b/collections/motoko/src/btreemap_stable.mo @@ -16,8 +16,8 @@ actor { var map = Map.init( Memory.RegionMemory(region), - BytesConverter.NAT64_CONVERTER, - BytesConverter.NAT64_CONVERTER, + BytesConverter.n64conv, + BytesConverter.n64conv ); let rand = Random.new(null, 42); From 2a44e70d6badeb64b7faa323c09622adef4bc50f Mon Sep 17 00:00:00 2001 From: Claudio Russo Date: Fri, 6 Oct 2023 00:14:55 +0100 Subject: [PATCH 04/10] adjust to API changes --- collections/motoko/src/btreemap_stable.mo | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/collections/motoko/src/btreemap_stable.mo b/collections/motoko/src/btreemap_stable.mo index 33ae2e11..1d5bb538 100644 --- a/collections/motoko/src/btreemap_stable.mo +++ b/collections/motoko/src/btreemap_stable.mo @@ -13,20 +13,20 @@ import Memory "mo:StableBTree/modules/memory"; actor { stable let profiling = Profiling.init(); stable var region = Region.new(); - + let n64conv = BytesConverter.n64conv; var map = Map.init( Memory.RegionMemory(region), - BytesConverter.n64conv, - BytesConverter.n64conv + n64conv, + n64conv ); - + let rand = Random.new(null, 42); public func generate(size : Nat32) : async () { let rand = Random.new(?size, 1); let iter = Iter.map(rand, func x = (x, x)); for ((k, v) in iter) { - ignore map.insert(k, v); + ignore map.insert(k, n64conv, v, n64conv); }; }; public query func get_mem() : async (Nat, Nat, Nat) { @@ -36,20 +36,20 @@ actor { public func batch_get(n : Nat) : async () { for (_ in Iter.range(1, n)) { let x = Option.get(rand.next(), 0); - ignore map.get(x); + ignore map.get(x, n64conv, n64conv); }; }; public func batch_put(n : Nat) : async () { for (_ in Iter.range(1, n)) { let k = Option.get(rand.next(), 0); - ignore map.insert(k, k); + ignore map.insert(k, n64conv, k, n64conv); }; }; public func batch_remove(n : Nat) : async () { let rand = Random.new(null, 1); for (_ in Iter.range(1, n)) { let x = Option.get(rand.next(), 0); - ignore map.remove(x); + ignore map.remove(x, n64conv, n64conv); }; }; }; From f1c7f96ac617eda5eba578b9a53066a0bd104def Mon Sep 17 00:00:00 2001 From: Claudio Russo Date: Fri, 6 Oct 2023 00:57:02 +0100 Subject: [PATCH 05/10] disablec crashing rust test --- collections/perf.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/collections/perf.sh b/collections/perf.sh index ce2a8408..dd88e8fc 100644 --- a/collections/perf.sh +++ b/collections/perf.sh @@ -14,7 +14,8 @@ let vector = wasm_profiling("motoko/.dfx/local/canisters/vector/vector.wasm", re let hashmap_rs = wasm_profiling("rust/.dfx/local/canisters/hashmap/hashmap.wasm", record { start_page = 1 }); let btreemap_rs = wasm_profiling("rust/.dfx/local/canisters/btreemap/btreemap.wasm", record { start_page = 1 }); -let btreemap_stable_rs = wasm_profiling("rust/.dfx/local/canisters/btreemap_stable/btreemap_stable.wasm", record { start_page = 1 }); +// disabling due to crash +//let btreemap_stable_rs = wasm_profiling("rust/.dfx/local/canisters/btreemap_stable/btreemap_stable.wasm", record { start_page = 1 }); let heap_rs = wasm_profiling("rust/.dfx/local/canisters/heap/heap.wasm", record { start_page = 1 }); let heap_stable_rs = wasm_profiling("rust/.dfx/local/canisters/heap_stable/heap_stable.wasm", record { start_page = 1 }); let imrc_hashmap_rs = wasm_profiling("rust/.dfx/local/canisters/imrc_hashmap/imrc_hashmap.wasm", record { start_page = 1 }); @@ -91,7 +92,8 @@ output(file, "\n## Stable structures\n\n| |binary_size|generate 50k|max mem|batc perf(btree, "btree", init_size, batch_size); perf(btree_stable, "btree_stable", init_size, batch_size); perf(btreemap_rs, "btreemap_rs", init_size, batch_size); -perf(btreemap_stable_rs, "btreemap_stable_rs", init_size, batch_size); +//disabling due to crash +//perf(btreemap_stable_rs, "btreemap_stable_rs", init_size, batch_size); perf(heap_rs, "heap_rs", init_size, batch_size); perf(heap_stable_rs, "heap_stable_rs", init_size, batch_size); perf(vector_rs, "vec_rs", init_size, batch_size); From 29feadf884834b2a8b4e4456339f172d94ea9a9f Mon Sep 17 00:00:00 2001 From: Claudio Russo Date: Fri, 6 Oct 2023 02:02:14 +0100 Subject: [PATCH 06/10] focus on collections --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 36473db0..4ee86b25 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ -APPS = dapps collections crypto pub-sub heartbeat motoko +#APPS = dapps collections crypto pub-sub heartbeat motoko +APPS = collections all: $(foreach test_dir,$(APPS),make -C $(test_dir) &&) true From ab661cf8607ca0fbc885758ff40eac1d49a92550 Mon Sep 17 00:00:00 2001 From: Claudio Russo Date: Thu, 5 Oct 2023 21:34:02 -0400 Subject: [PATCH 07/10] Update collections/motoko/mops.template.toml --- collections/motoko/mops.template.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collections/motoko/mops.template.toml b/collections/motoko/mops.template.toml index 7ce62753..797d328d 100644 --- a/collections/motoko/mops.template.toml +++ b/collections/motoko/mops.template.toml @@ -4,4 +4,4 @@ stableheapbtreemap = "1.3.0" map = "9.0.0" splay = "0.1.0" vector = "0.2.0" -StableBTree = "https://github.com/crusso/MotokoStableBTree/tree/claudio" +StableBTree = "https://github.com/crusso/MotokoStableBTree#claudio" From 30316970abc07c17c11e9c55cddbbd1116019afe Mon Sep 17 00:00:00 2001 From: Claudio Russo Date: Fri, 6 Oct 2023 11:37:12 +0100 Subject: [PATCH 08/10] re-enable btreemap_stable_rs --- collections/perf.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/collections/perf.sh b/collections/perf.sh index dd88e8fc..ce2a8408 100644 --- a/collections/perf.sh +++ b/collections/perf.sh @@ -14,8 +14,7 @@ let vector = wasm_profiling("motoko/.dfx/local/canisters/vector/vector.wasm", re let hashmap_rs = wasm_profiling("rust/.dfx/local/canisters/hashmap/hashmap.wasm", record { start_page = 1 }); let btreemap_rs = wasm_profiling("rust/.dfx/local/canisters/btreemap/btreemap.wasm", record { start_page = 1 }); -// disabling due to crash -//let btreemap_stable_rs = wasm_profiling("rust/.dfx/local/canisters/btreemap_stable/btreemap_stable.wasm", record { start_page = 1 }); +let btreemap_stable_rs = wasm_profiling("rust/.dfx/local/canisters/btreemap_stable/btreemap_stable.wasm", record { start_page = 1 }); let heap_rs = wasm_profiling("rust/.dfx/local/canisters/heap/heap.wasm", record { start_page = 1 }); let heap_stable_rs = wasm_profiling("rust/.dfx/local/canisters/heap_stable/heap_stable.wasm", record { start_page = 1 }); let imrc_hashmap_rs = wasm_profiling("rust/.dfx/local/canisters/imrc_hashmap/imrc_hashmap.wasm", record { start_page = 1 }); @@ -92,8 +91,7 @@ output(file, "\n## Stable structures\n\n| |binary_size|generate 50k|max mem|batc perf(btree, "btree", init_size, batch_size); perf(btree_stable, "btree_stable", init_size, batch_size); perf(btreemap_rs, "btreemap_rs", init_size, batch_size); -//disabling due to crash -//perf(btreemap_stable_rs, "btreemap_stable_rs", init_size, batch_size); +perf(btreemap_stable_rs, "btreemap_stable_rs", init_size, batch_size); perf(heap_rs, "heap_rs", init_size, batch_size); perf(heap_stable_rs, "heap_stable_rs", init_size, batch_size); perf(vector_rs, "vec_rs", init_size, batch_size); From 8d9e0a892afbc6b2bf017857bd927f4cf3e25548 Mon Sep 17 00:00:00 2001 From: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> Date: Tue, 10 Oct 2023 20:46:05 -0700 Subject: [PATCH 09/10] bump ic-repl (#96) * Bump ic-repl/ic-wasm to fix the heap out of bound bug in `__get_profiling` * bump profiling trace to 256M (8M for collection) * Append version info at the end of the report --- .github/workflows/perf.yml | 27 ++++++------ Cargo.lock | 86 ++++++++++++++++++-------------------- Makefile | 10 +++++ collections/perf.sh | 39 +++++++++-------- crypto/perf.sh | 4 +- dapps/basic_dao.sh | 4 +- dapps/nft.sh | 4 +- motoko/gc.sh | 11 ++--- prelude.sh | 2 + utils.mk | 6 ++- utils/motoko/Profiling.mo | 2 +- utils/rust/src/lib.rs | 2 +- 12 files changed, 106 insertions(+), 91 deletions(-) diff --git a/.github/workflows/perf.yml b/.github/workflows/perf.yml index 060f568a..6b7a218d 100644 --- a/.github/workflows/perf.yml +++ b/.github/workflows/perf.yml @@ -7,14 +7,15 @@ on: jobs: perf: - runs-on: ubuntu-latest + runs-on: macos-latest strategy: fail-fast: false env: - DFX_VERSION: 0.15.0 - IC_REPL_VERSION: 0.5.0 + DFX_VERSION: 0.15.1 + IC_REPL_VERSION: 0.5.1 MOC_VERSION: 0.10.0 - IC_WASM_VERSION: 0.5.1 + IC_WASM_VERSION: 0.6.0 + RUSTC_VERSION: 1.73.0 steps: - uses: actions/checkout@v3 - name: Checkout out gh-pages report @@ -32,7 +33,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: stable + toolchain: ${{ env.RUSTC_VERSION }} override: true target: wasm32-unknown-unknown - name: Cache cargo build @@ -58,16 +59,16 @@ jobs: - name: Install ic-repl, mops, dfx, and moc run: | echo y | DFX_VERSION=$DFX_VERSION bash -ci "$(curl -fsSL https://smartcontracts.org/install.sh)" - wget https://github.com/chenyan2002/ic-repl/releases/download/$IC_REPL_VERSION/ic-repl-linux64 - cp ./ic-repl-linux64 /usr/local/bin/ic-repl + wget https://github.com/chenyan2002/ic-repl/releases/download/$IC_REPL_VERSION/ic-repl-macos + cp ./ic-repl-macos /usr/local/bin/ic-repl chmod a+x /usr/local/bin/ic-repl npm i -g ic-mops dfx cache install cd $(dfx cache show) - wget https://github.com/dfinity/motoko/releases/download/$MOC_VERSION/motoko-Linux-x86_64-$MOC_VERSION.tar.gz - tar zxvf motoko-Linux-x86_64-$MOC_VERSION.tar.gz - wget https://github.com/dfinity/ic-wasm/releases/download/$IC_WASM_VERSION/ic-wasm-linux64 - cp ./ic-wasm-linux64 /usr/local/bin/ic-wasm + wget https://github.com/dfinity/motoko/releases/download/$MOC_VERSION/motoko-Darwin-x86_64-$MOC_VERSION.tar.gz + tar zxvf motoko-Darwin-x86_64-$MOC_VERSION.tar.gz + wget https://github.com/dfinity/ic-wasm/releases/download/$IC_WASM_VERSION/ic-wasm-macos + cp ./ic-wasm-macos /usr/local/bin/ic-wasm chmod a+x /usr/local/bin/ic-wasm - name: Setup system subnet and start dfx run: | @@ -82,7 +83,9 @@ jobs: dfx stop dfx start --clean --background - name: Run perf - run: make + run: | + make + make emit_version - name: Generate table if: github.event_name == 'pull_request' env: diff --git a/Cargo.lock b/Cargo.lock index eaebbe49..936f32e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -92,15 +92,15 @@ dependencies = [ [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "candid" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "749938f355699c7dd0975e505d54541cd1d84db239374470bdf500a5d885530a" +checksum = "aa0f00717c71b8e9ee4c090b4880ec2418c8506bb6828a2c72df72d3896e905d" dependencies = [ "anyhow", "binread", @@ -132,7 +132,7 @@ dependencies = [ "lazy_static", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -295,7 +295,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -355,9 +355,9 @@ checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" [[package]] name = "hashmap" @@ -493,9 +493,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ "equivalent", "hashbrown", @@ -515,15 +515,15 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.148" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "memchr" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "num-bigint" @@ -549,9 +549,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -574,7 +574,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -603,13 +603,13 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pretty" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "563c9d701c3a31dfffaaf9ce23507ba09cbe0b9125ba176d15e629b0235e9acc" +checksum = "b55c4d17d994b637e2f4daf6e5dc5d660d209d5642377d675d7a1c3ab69fa579" dependencies = [ "arrayvec", "typed-arena", - "unicode-segmentation", + "unicode-width", ] [[package]] @@ -624,9 +624,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -715,7 +715,7 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -741,9 +741,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -813,9 +813,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -824,31 +824,31 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" dependencies = [ "winapi-util", ] [[package]] name = "thiserror" -version = "1.0.48" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.48" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -895,17 +895,11 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "utils" @@ -958,9 +952,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] @@ -973,9 +967,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winnow" -version = "0.5.15" +version = "0.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +checksum = "037711d82167854aff2018dfd193aa0fef5370f456732f0d5a0c59b0f1b4b907" dependencies = [ "memchr", ] diff --git a/Makefile b/Makefile index 36473db0..6e335a94 100644 --- a/Makefile +++ b/Makefile @@ -2,3 +2,13 @@ APPS = dapps collections crypto pub-sub heartbeat motoko all: $(foreach test_dir,$(APPS),make -C $(test_dir) &&) true + +emit_version: + for f in _out/*/README.md; do \ + echo "\n> ## Environment" >> $$f; \ + (printf "> * "; dfx --version) >> $$f; \ + (printf "> * "; $$(dfx cache show)/moc --version) >> $$f; \ + (printf "> * "; rustc --version) >> $$f; \ + (printf "> * "; ic-repl --version) >> $$f; \ + (printf "> * "; ic-wasm --version) >> $$f; \ + done diff --git a/collections/perf.sh b/collections/perf.sh index e3a82060..5c67c89c 100644 --- a/collections/perf.sh +++ b/collections/perf.sh @@ -1,24 +1,27 @@ #!ic-repl load "../prelude.sh"; -let hashmap = wasm_profiling("motoko/.dfx/local/canisters/hashmap/hashmap.wasm", record { start_page = 16 }); -let triemap = wasm_profiling("motoko/.dfx/local/canisters/triemap/triemap.wasm", record { start_page = 16 }); -let rbtree = wasm_profiling("motoko/.dfx/local/canisters/rbtree/rbtree.wasm", record { start_page = 16 }); -let splay = wasm_profiling("motoko/.dfx/local/canisters/splay/splay.wasm", record { start_page = 16 }); -let btree = wasm_profiling("motoko/.dfx/local/canisters/btreemap/btreemap.wasm", record { start_page = 16 }); -let zhenya = wasm_profiling("motoko/.dfx/local/canisters/zhenya_hashmap/zhenya_hashmap.wasm", record { start_page = 16 }); -let heap = wasm_profiling("motoko/.dfx/local/canisters/heap/heap.wasm", record { start_page = 16 }); -let buffer = wasm_profiling("motoko/.dfx/local/canisters/buffer/buffer.wasm", record { start_page = 16 }); -let vector = wasm_profiling("motoko/.dfx/local/canisters/vector/vector.wasm", record { start_page = 16 }); - -let hashmap_rs = wasm_profiling("rust/.dfx/local/canisters/hashmap/hashmap.wasm", record { start_page = 1 }); -let btreemap_rs = wasm_profiling("rust/.dfx/local/canisters/btreemap/btreemap.wasm", record { start_page = 1 }); -let btreemap_stable_rs = wasm_profiling("rust/.dfx/local/canisters/btreemap_stable/btreemap_stable.wasm", record { start_page = 1 }); -let heap_rs = wasm_profiling("rust/.dfx/local/canisters/heap/heap.wasm", record { start_page = 1 }); -let heap_stable_rs = wasm_profiling("rust/.dfx/local/canisters/heap_stable/heap_stable.wasm", record { start_page = 1 }); -let imrc_hashmap_rs = wasm_profiling("rust/.dfx/local/canisters/imrc_hashmap/imrc_hashmap.wasm", record { start_page = 1 }); -let vector_rs = wasm_profiling("rust/.dfx/local/canisters/vector/vector.wasm", record { start_page = 1 }); -let vector_stable_rs = wasm_profiling("rust/.dfx/local/canisters/vector_stable/vector_stable.wasm", record { start_page = 1 }); +// use smaller page_limit to speed things up, since the whole trace is too large even with 256M. +let mo_config = record { start_page = 16; page_limit = 128 }; +let hashmap = wasm_profiling("motoko/.dfx/local/canisters/hashmap/hashmap.wasm", mo_config); +let triemap = wasm_profiling("motoko/.dfx/local/canisters/triemap/triemap.wasm", mo_config); +let rbtree = wasm_profiling("motoko/.dfx/local/canisters/rbtree/rbtree.wasm", mo_config); +let splay = wasm_profiling("motoko/.dfx/local/canisters/splay/splay.wasm", mo_config); +let btree = wasm_profiling("motoko/.dfx/local/canisters/btreemap/btreemap.wasm", mo_config); +let zhenya = wasm_profiling("motoko/.dfx/local/canisters/zhenya_hashmap/zhenya_hashmap.wasm", mo_config); +let heap = wasm_profiling("motoko/.dfx/local/canisters/heap/heap.wasm", mo_config); +let buffer = wasm_profiling("motoko/.dfx/local/canisters/buffer/buffer.wasm", mo_config); +let vector = wasm_profiling("motoko/.dfx/local/canisters/vector/vector.wasm", mo_config); + +let rs_config = record { start_page = 1; page_limit = 128 }; +let hashmap_rs = wasm_profiling("rust/.dfx/local/canisters/hashmap/hashmap.wasm", rs_config); +let btreemap_rs = wasm_profiling("rust/.dfx/local/canisters/btreemap/btreemap.wasm", rs_config); +let btreemap_stable_rs = wasm_profiling("rust/.dfx/local/canisters/btreemap_stable/btreemap_stable.wasm", rs_config); +let heap_rs = wasm_profiling("rust/.dfx/local/canisters/heap/heap.wasm", rs_config); +let heap_stable_rs = wasm_profiling("rust/.dfx/local/canisters/heap_stable/heap_stable.wasm", rs_config); +let imrc_hashmap_rs = wasm_profiling("rust/.dfx/local/canisters/imrc_hashmap/imrc_hashmap.wasm", rs_config); +let vector_rs = wasm_profiling("rust/.dfx/local/canisters/vector/vector.wasm", rs_config); +let vector_stable_rs = wasm_profiling("rust/.dfx/local/canisters/vector_stable/vector_stable.wasm", rs_config); //let movm_rs = wasm_profiling("rust/.dfx/local/canisters/movm/movm.wasm"); //let movm_dynamic_rs = wasm_profiling("rust/.dfx/local/canisters/movm_dynamic/movm_dynamic.wasm"); diff --git a/crypto/perf.sh b/crypto/perf.sh index e5e2285c..968ec0b5 100644 --- a/crypto/perf.sh +++ b/crypto/perf.sh @@ -3,8 +3,8 @@ load "../prelude.sh"; let sha_mo = wasm_profiling("motoko/.dfx/local/canisters/sha/sha.wasm"); let sha_rs = wasm_profiling("rust/.dfx/local/canisters/sha/sha.wasm"); -let map_mo = wasm_profiling("motoko/.dfx/local/canisters/certified_map/certified_map.wasm", record { start_page = 16 }); -let map_rs = wasm_profiling("rust/.dfx/local/canisters/certified_map/certified_map.wasm", record { start_page = 1 }); +let map_mo = wasm_profiling("motoko/.dfx/local/canisters/certified_map/certified_map.wasm", mo_config); +let map_rs = wasm_profiling("rust/.dfx/local/canisters/certified_map/certified_map.wasm", rs_config); let sample = file("sample_wasm.bin"); let file = "README.md"; diff --git a/dapps/basic_dao.sh b/dapps/basic_dao.sh index 01cc3cd5..46f4d0d1 100644 --- a/dapps/basic_dao.sh +++ b/dapps/basic_dao.sh @@ -8,8 +8,8 @@ identity cathy; identity dory; identity genesis; -let motoko = wasm_profiling("motoko/.dfx/local/canisters/basic_dao/basic_dao.wasm", record { start_page = 16 }); -let rust = wasm_profiling("rust/.dfx/local/canisters/basic_dao/basic_dao.wasm", record { start_page = 1 }); +let motoko = wasm_profiling("motoko/.dfx/local/canisters/basic_dao/basic_dao.wasm", mo_config); +let rust = wasm_profiling("rust/.dfx/local/canisters/basic_dao/basic_dao.wasm", rs_config); let file = "README.md"; output(file, "\n## Basic DAO\n\n| |binary_size|init|transfer_token|submit_proposal|vote_proposal|upgrade|\n|--|--:|--:|--:|--:|--:|--:|\n"); diff --git a/dapps/nft.sh b/dapps/nft.sh index 437c87aa..b1602b01 100644 --- a/dapps/nft.sh +++ b/dapps/nft.sh @@ -5,8 +5,8 @@ load "../prelude.sh"; identity alice; identity bob; -let motoko = wasm_profiling("motoko/.dfx/local/canisters/dip721_nft/dip721_nft.wasm", record { start_page = 16 }); -let rust = wasm_profiling("rust/.dfx/local/canisters/dip721_nft/dip721_nft.wasm", record { start_page = 1 }); +let motoko = wasm_profiling("motoko/.dfx/local/canisters/dip721_nft/dip721_nft.wasm", mo_config); +let rust = wasm_profiling("rust/.dfx/local/canisters/dip721_nft/dip721_nft.wasm", rs_config); let file = "README.md"; output(file, "\n## DIP721 NFT\n\n| |binary_size|init|mint_token|transfer_token|upgrade|\n|--|--:|--:|--:|--:|--:|\n"); diff --git a/motoko/gc.sh b/motoko/gc.sh index a70e1298..14dfee0f 100644 --- a/motoko/gc.sh +++ b/motoko/gc.sh @@ -1,11 +1,12 @@ #!ic-repl load "../prelude.sh"; -let default = wasm_profiling("motoko/default.wasm", record { trace_only_funcs = vec{"schedule_copying_gc"} }); -let copying = wasm_profiling("motoko/copying.wasm", record { trace_only_funcs = vec {"copying_gc"} }); -let compacting = wasm_profiling("motoko/compacting.wasm", record { trace_only_funcs = vec{"compacting_gc"} }); -let generational = wasm_profiling("motoko/generational.wasm", record { trace_only_funcs = vec{"generational_gc"} }); -let incremental = wasm_profiling("motoko/incremental.wasm", record { trace_only_funcs = vec{"incremental_gc"} }); +let mo_config = record { start_page = 16; page_limit = 128 }; +let default = wasm_profiling("motoko/default.wasm", concat(mo_config, record { trace_only_funcs = vec{"schedule_copying_gc"} })); +let copying = wasm_profiling("motoko/copying.wasm", concat(mo_config, record { trace_only_funcs = vec {"copying_gc"} })); +let compacting = wasm_profiling("motoko/compacting.wasm", concat(mo_config, record { trace_only_funcs = vec{"compacting_gc"} })); +let generational = wasm_profiling("motoko/generational.wasm", concat(mo_config, record { trace_only_funcs = vec{"generational_gc"} })); +let incremental = wasm_profiling("motoko/incremental.wasm", concat(mo_config, record { trace_only_funcs = vec{"incremental_gc"} })); let file = "README.md"; output(file, "\n\n## Garbage Collection\n\n| |generate 700k|max mem|batch_get 50|batch_put 50|batch_remove 50|\n|--:|--:|--:|--:|--:|--:|\n"); diff --git a/prelude.sh b/prelude.sh index 58e10401..7f0f880d 100644 --- a/prelude.sh +++ b/prelude.sh @@ -33,3 +33,5 @@ function get_memory(cid) { _.memory_size }; +let mo_config = record { start_page = 16; page_limit = 4096 }; +let rs_config = record { start_page = 1; page_limit = 4096 }; diff --git a/utils.mk b/utils.mk index 11982e36..2f55440c 100644 --- a/utils.mk +++ b/utils.mk @@ -35,12 +35,14 @@ endef define perf set -e; \ $(call prepare_perf,$(1)); \ - ic-repl ../../$(1)/$(2) + ic-repl ../../$(1)/$(2); \ + du -h ../../_out endef define perf_two set -e; \ $(call prepare_perf,$(1)); \ ic-repl ../../$(1)/$(2); \ - ic-repl ../../$(1)/$(3) + ic-repl ../../$(1)/$(3); \ + du -h ../../_out endef diff --git a/utils/motoko/Profiling.mo b/utils/motoko/Profiling.mo index f43a4558..7f91dcad 100644 --- a/utils/motoko/Profiling.mo +++ b/utils/motoko/Profiling.mo @@ -3,7 +3,7 @@ import Region "mo:base/Region"; module { public func init() : Region.Region { let profiling = Region.new(); - ignore Region.grow(profiling, 32); + ignore Region.grow(profiling, 4096); profiling; }; } diff --git a/utils/rust/src/lib.rs b/utils/rust/src/lib.rs index 2f983f12..08fac1f9 100644 --- a/utils/rust/src/lib.rs +++ b/utils/rust/src/lib.rs @@ -64,7 +64,7 @@ pub fn get_upgrade_memory() -> Memory { pub fn profiling_init() { let memory = MEMORY_MANAGER.with(|m| m.borrow().get(PROFILING)); - memory.grow(32); + memory.grow(4096); } pub fn save_stable(val: &T) { From f2f0bcc8a5b49656c47976d75deeddc03d8343d3 Mon Sep 17 00:00:00 2001 From: Yan Chen Date: Tue, 10 Oct 2023 21:49:28 -0700 Subject: [PATCH 10/10] fix --- collections/perf.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collections/perf.sh b/collections/perf.sh index 331c6053..a7af3b82 100644 --- a/collections/perf.sh +++ b/collections/perf.sh @@ -8,7 +8,7 @@ let triemap = wasm_profiling("motoko/.dfx/local/canisters/triemap/triemap.wasm", let rbtree = wasm_profiling("motoko/.dfx/local/canisters/rbtree/rbtree.wasm", mo_config); let splay = wasm_profiling("motoko/.dfx/local/canisters/splay/splay.wasm", mo_config); let btree = wasm_profiling("motoko/.dfx/local/canisters/btreemap/btreemap.wasm", mo_config); -let btree_stable = wasm_profiling("motoko/.dfx/local/canisters/btreemap_stable/btreemap_stable.wasm", record { start_page = 16 }); +let btree_stable = wasm_profiling("motoko/.dfx/local/canisters/btreemap_stable/btreemap_stable.wasm", mo_config); let zhenya = wasm_profiling("motoko/.dfx/local/canisters/zhenya_hashmap/zhenya_hashmap.wasm", mo_config); let heap = wasm_profiling("motoko/.dfx/local/canisters/heap/heap.wasm", mo_config); let buffer = wasm_profiling("motoko/.dfx/local/canisters/buffer/buffer.wasm", mo_config);