diff --git a/.github/workflows/perf.yml b/.github/workflows/perf.yml index 6112c761..e678aebf 100644 --- a/.github/workflows/perf.yml +++ b/.github/workflows/perf.yml @@ -16,6 +16,7 @@ jobs: MOC_VERSION: 0.10.4 IC_WASM_VERSION: 0.7.0 RUSTC_VERSION: 1.75.0 + MOC_ARTIFACT: 1242507845 steps: - uses: actions/checkout@v3 - name: Checkout out gh-pages report @@ -64,9 +65,10 @@ jobs: 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-Darwin-x86_64-$MOC_VERSION.tar.gz - tar zxvf motoko-Darwin-x86_64-$MOC_VERSION.tar.gz + wget https://nightly.link/dfinity/motoko/actions/artifacts/$MOC_ARTIFACT.zip + 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-macos cp ./ic-wasm-macos /usr/local/bin/ic-wasm chmod a+x /usr/local/bin/ic-wasm diff --git a/collections/motoko/src/ZhenyaHashmap.mo b/collections/motoko/src/ZhenyaHashmap.mo index 7d2d20e9..55205f9d 100644 --- a/collections/motoko/src/ZhenyaHashmap.mo +++ b/collections/motoko/src/ZhenyaHashmap.mo @@ -5,12 +5,18 @@ 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); - let hash : HashMap.HashUtils = (f_hash, Nat64.equal); + + + // avoid boxed hashes + func hashNat64(key: Nat64) : Nat32 { + Prim.nat64ToNat32(key & 0x7ff_ffff); // Nat32 is 27-bit + }; + + let hash : HashMap.HashUtils = (hashNat64, func (x,y) = x == y); + 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..ea8f1b3e 100644 --- a/collections/motoko/src/hashmap.mo +++ b/collections/motoko/src/hashmap.mo @@ -9,7 +9,6 @@ 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)] = []; diff --git a/collections/motoko/src/random.mo b/collections/motoko/src/random.mo index 4a4222fb..2b67db8c 100644 --- a/collections/motoko/src/random.mo +++ b/collections/motoko/src/random.mo @@ -19,7 +19,7 @@ module { }; }; state := state * 48271 % modulus; - ?state; + ?(state >> 4); }; }; public func get_memory(): (Nat,Nat,Nat) {