Closed twoeths closed 4 months ago
✔️ no performance regression detected
by benchmarkbot/action
the performance of simd implementation really depends on the cpu, below is simd vs digest64
in CI (ubuntu), simd is just a little bit faster
in my environment (Mac M1) simd is ~20% faster
digest64 vs hash4Input64s vs hash8HashObjects
✓ digest64 200092 times 6.206878 ops/s 161.1116 ms/op - 60 runs 10.3 s
✓ hash 200092 times using hash4Input64s 7.460423 ops/s 134.0406 ms/op - 72 runs 10.2 s
✓ hash 200092 times using hash8HashObjects 7.834839 ops/s 127.6350 ms/op - 76 runs 10.2 s
digest64 vs hash4Input64s vs hash8HashObjects
✓ digest64 200092 times 4.908615 ops/s 203.7235 ms/op - 47 runs 10.2 s
✓ hash 200092 times using hash4Input64s 9.644699 ops/s 103.6839 ms/op - 94 runs 10.3 s
✓ hash 200092 times using hash8HashObjects 9.390349 ops/s 106.4923 ms/op - 90 runs 10.1 s
Motivation
SIMD is available in assemblyscript, it supports v128 data structure which mean we can hash 4 inputs in parallel
Description
assembly/simd.ts
hash4Input64s(inputs: Uint8Array[]): Uint8Array[]
hash8HashObjects(inputs: HashObject[])
Closes #356