bitcoinjs / tiny-secp256k1

A tiny secp256k1 native/JS wrapper
MIT License
86 stars 55 forks source link

Two times speed regression between `2.2.2` and `2.2.3` #123

Open mahnunchik opened 1 year ago

mahnunchik commented 1 year ago

I've faced with the speed regression between version 2.2.2 and 2.2.3 for pointFromScalar method.

Simple test:

import * as secp256k1 from 'tiny-secp256k1';
import crypto from 'crypto';

const bufs = Array(10_000).fill(undefined).map(() => crypto.randomBytes(32));

for (const buf of bufs) {
  secp256k1.pointFromScalar(buf);
}
% time node tiny-222.js
node tiny-222.js  0,79s user 0,02s system 103% cpu 0,783 total
% time node tiny-223.js
node tiny-223.js  1,34s user 0,02s system 101% cpu 1,335 total

So at least pointFromScalar method became two times slower.

junderw commented 1 year ago

Testing locally, #124

2.2.2
tiny-secp256k1 (WASM): 99.09 us/op (10091.34 op/s), ±1.19 %

2.2.3
tiny-secp256k1 (WASM): 176.99 us/op (5649.99 op/s), ±1.03 %

remove lowmemory (#124)
tiny-secp256k1 (WASM): 94.00 us/op (10638.65 op/s), ±1.37 %
junderw commented 1 year ago

Please check if there are any other regressions you care about.

mahnunchik commented 1 year ago