From a38b430d95336d9fe03725d1b8c098386c352310 Mon Sep 17 00:00:00 2001 From: Yan Chen Date: Tue, 2 May 2023 17:26:11 -0700 Subject: [PATCH 1/9] perf from moc artifact --- .github/workflows/perf.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/perf.yml b/.github/workflows/perf.yml index 11d49145..cce19d80 100644 --- a/.github/workflows/perf.yml +++ b/.github/workflows/perf.yml @@ -14,7 +14,7 @@ jobs: DFX_VERSION: 0.13.1 VESSEL_VERSION: v0.6.4 IC_REPL_VERSION: 0.3.18 - MOC_VERSION: 0.8.7 + MOC_ARTIFACT: 676558399 steps: - uses: actions/checkout@v3 - name: Checkout out gh-pages report @@ -56,9 +56,9 @@ jobs: cp ./vessel-linux64 /usr/local/bin/vessel chmod a+x /usr/local/bin/vessel dfx cache install - cd $(dfx cache show) - wget https://github.com/dfinity/motoko/releases/download/$MOC_VERSION/motoko-linux64-$MOC_VERSION.tar.gz - tar zxvf motoko-linux64-$MOC_VERSION.tar.gz + wget https://nightly.link/dfinity/motoko/actions/artifacts/$MOC_ARTIFACT.zip + unzip $MOC_ARTIFACT.zip + cp bin/moc $(dfx cache show) - name: Start dfx run: | dfx start --background From 510bad26c25b1220f742ac7511719b9e097cb4c9 Mon Sep 17 00:00:00 2001 From: Yan Chen Date: Tue, 2 May 2023 17:30:37 -0700 Subject: [PATCH 2/9] fix --- .github/workflows/perf.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/perf.yml b/.github/workflows/perf.yml index cce19d80..904e2066 100644 --- a/.github/workflows/perf.yml +++ b/.github/workflows/perf.yml @@ -58,7 +58,8 @@ jobs: dfx cache install wget https://nightly.link/dfinity/motoko/actions/artifacts/$MOC_ARTIFACT.zip unzip $MOC_ARTIFACT.zip - cp bin/moc $(dfx cache show) + chmod a+x bin/moc + cp -rf bin/moc $(dfx cache show) - name: Start dfx run: | dfx start --background From 48d0853439606946541f24b511655a65fddae4e4 Mon Sep 17 00:00:00 2001 From: Yan Chen Date: Wed, 3 May 2023 09:56:11 -0700 Subject: [PATCH 3/9] trigger CI From 71cfcdea345c20db5b37b5ffe7e04226a433f1eb Mon Sep 17 00:00:00 2001 From: Claudio Russo Date: Tue, 13 Feb 2024 19:42:09 +0000 Subject: [PATCH 4/9] Update .github/workflows/perf.yml --- .github/workflows/perf.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/perf.yml b/.github/workflows/perf.yml index dafd32d5..f42fd4f5 100644 --- a/.github/workflows/perf.yml +++ b/.github/workflows/perf.yml @@ -71,9 +71,6 @@ jobs: cp -rf bin/moc $(dfx cache show) wget https://github.com/dfinity/ic-wasm/releases/download/$IC_WASM_VERSION/ic-wasm-linux64 cp ./ic-wasm-linux64 /usr/local/bin/ic-wasm - cd $(dfx cache show) - 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 From 81ed4c774bbc352e04952dad3a14cc244c052a76 Mon Sep 17 00:00:00 2001 From: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> Date: Tue, 13 Feb 2024 16:55:07 -0800 Subject: [PATCH 5/9] retrigger CI --- .github/workflows/perf.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/perf.yml b/.github/workflows/perf.yml index f42fd4f5..e678aebf 100644 --- a/.github/workflows/perf.yml +++ b/.github/workflows/perf.yml @@ -69,8 +69,6 @@ jobs: unzip $MOC_ARTIFACT.zip chmod a+x bin/moc cp -rf bin/moc $(dfx cache show) - 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/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 From 1b763c41fd5d27398e05262985a3cf21c7259330 Mon Sep 17 00:00:00 2001 From: Claudio Russo Date: Wed, 14 Feb 2024 14:26:11 +0000 Subject: [PATCH 6/9] use better hash function --- collections/motoko/src/ZhenyaHashmap.mo | 6 +++--- collections/motoko/src/hashmap.mo | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/collections/motoko/src/ZhenyaHashmap.mo b/collections/motoko/src/ZhenyaHashmap.mo index 7d2d20e9..4fd82303 100644 --- a/collections/motoko/src/ZhenyaHashmap.mo +++ b/collections/motoko/src/ZhenyaHashmap.mo @@ -5,11 +5,11 @@ import Iter "mo:base/Iter"; import Option "mo:base/Option"; import Random "random"; import Profiling "../../../utils/motoko/Profiling"; - +import Prim "mo:prim"; actor { stable let profiling = Profiling.init(); - - func f_hash(x : Nat64) : Nat32 = Hash.hash(Nat64.toNat x); + + func f_hash(x : Nat64) : Nat32 = Prim.nat64ToNat32(x & 0xffffffff); let hash : HashMap.HashUtils = (f_hash, Nat64.equal); stable var map = HashMap.new(); let rand = Random.new(null, 42); diff --git a/collections/motoko/src/hashmap.mo b/collections/motoko/src/hashmap.mo index 92b70983..f8ae4fc1 100644 --- a/collections/motoko/src/hashmap.mo +++ b/collections/motoko/src/hashmap.mo @@ -9,7 +9,7 @@ import Profiling "../../../utils/motoko/Profiling"; actor { stable let profiling = Profiling.init(); - + func hash(x: Nat64) : Nat32 = Hash.hash(Nat64.toNat x); var map = HashMap.HashMap(0, Nat64.equal, hash); stable var stableMap: [(Nat64, Nat64)] = []; From 77a920eac12db696d2893778b75cf83a44df44a3 Mon Sep 17 00:00:00 2001 From: Claudio Russo Date: Wed, 14 Feb 2024 16:44:12 +0000 Subject: [PATCH 7/9] avoid boxing (changes baseline) --- collections/motoko/src/ZhenyaHashmap.mo | 2 +- collections/motoko/src/random.mo | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/collections/motoko/src/ZhenyaHashmap.mo b/collections/motoko/src/ZhenyaHashmap.mo index 4fd82303..378bab58 100644 --- a/collections/motoko/src/ZhenyaHashmap.mo +++ b/collections/motoko/src/ZhenyaHashmap.mo @@ -9,7 +9,7 @@ import Prim "mo:prim"; actor { stable let profiling = Profiling.init(); - func f_hash(x : Nat64) : Nat32 = Prim.nat64ToNat32(x & 0xffffffff); + func f_hash(x : Nat64) : Nat32 = Hash.hash(Nat64.toNat x); let hash : HashMap.HashUtils = (f_hash, Nat64.equal); stable var map = HashMap.new(); let rand = Random.new(null, 42); diff --git a/collections/motoko/src/random.mo b/collections/motoko/src/random.mo index 4a4222fb..b966d66e 100644 --- a/collections/motoko/src/random.mo +++ b/collections/motoko/src/random.mo @@ -4,7 +4,7 @@ import Prim "mo:⛔"; module { public class new(size: ?Nat32, seed: Nat64) { - let modulus : Nat64 = 0x7fffffff; + let modulus : Nat64 = 0xfffffff; //0x7fffffff; var state : Nat64 = seed; var ind : Nat32 = 0; From d54690b0520b462e3067470080cc78cace355d1f Mon Sep 17 00:00:00 2001 From: Claudio Russo Date: Wed, 14 Feb 2024 18:48:59 +0000 Subject: [PATCH 8/9] restore RNG; return 28 high bits instead to avoid boxing and duplication --- collections/motoko/src/random.mo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/collections/motoko/src/random.mo b/collections/motoko/src/random.mo index b966d66e..5e8ea58c 100644 --- a/collections/motoko/src/random.mo +++ b/collections/motoko/src/random.mo @@ -4,7 +4,7 @@ import Prim "mo:⛔"; module { public class new(size: ?Nat32, seed: Nat64) { - let modulus : Nat64 = 0xfffffff; //0x7fffffff; + let modulus : Nat64 = 0x7fffffff; var state : Nat64 = seed; var ind : Nat32 = 0; @@ -19,7 +19,7 @@ module { }; }; state := state * 48271 % modulus; - ?state; + ?(state>>4); }; }; public func get_memory(): (Nat,Nat,Nat) { From bc41fe4df4047f747c8f53e1ca0b960598511487 Mon Sep 17 00:00:00 2001 From: Claudio Russo Date: Wed, 14 Feb 2024 22:30:16 +0000 Subject: [PATCH 9/9] insert spaces --- collections/motoko/src/random.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collections/motoko/src/random.mo b/collections/motoko/src/random.mo index 5e8ea58c..2b67db8c 100644 --- a/collections/motoko/src/random.mo +++ b/collections/motoko/src/random.mo @@ -19,7 +19,7 @@ module { }; }; state := state * 48271 % modulus; - ?(state>>4); + ?(state >> 4); }; }; public func get_memory(): (Nat,Nat,Nat) {