I ran some quick benchmarks comparing wax vs hive-js on Node.js 20 (linux x64, 8-core server):
This is where wax (through wasm) dominates:
| Operation | wax | hive-js | Speedup |
|---|---|---|---|
| Sign 1 vote | 3,601 ops/s | 7 ops/s | 525x |
| Sign 20 votes | 1,998 ops/s | 7 ops/s | 267x |
| Encrypt memo (6B) | 43,110 ops/s | 37 ops/s | 1,152x |
| Encrypt memo (2KB) | 23,548 ops/s | 28 ops/s | 853x |
The secp256k1 wasm vs pure-javascript gap is massive - this alone justifies the switch.
Unfortunately... crossing wasm boundary hurts:
| Operation | wax | hive-js | |
|---|---|---|---|
| Account validation | 349K ops/s | 382K ops/s | hive-js slightly faster |
| Serialize 1 vote tx | 17K ops/s | 579K ops/s | hive-js 34x faster |
| Serialize 20 vote tx | 3.3K ops/s | 102K ops/s | hive-js 31x faster |
| vestsToHp (single) | 96K ops/s (10.4us) | 4.1M ops/s (0.2us) | hive-js 43x faster |
| vestsToHp (1000 accounts) | 9.5ms | 0.15ms | hive-js 63x faster |
For trivial operations like vestsToHp (which is just BigInt(vests) * BigInt(fund) / BigInt(shares)), the ~12.7us per call is almost entirely overhead from crossing the javascript-to-wasm boundary (converting javascript objects into a format that wasm understands, calling into it, and converting the result back).
A pure javascript implementation would be sub-microsecond.
Is it possible for helper functions that don't benefit from wasm (asset math like vestsToHp/hpToVests/hbdToHive, simple conversions), providing javascript-native fast paths that would eliminate the one area where hive-js still outperforms wax?
That's not a common because usually not called frequently and not taking long (absolute time), but this matters for batch-processing use cases, like idk, processing large data exports where these conversions happen a lot.
The crypto operations should obviously stay in wasm (the 500-1000x speedup is incredible). But is it still possible for the utility/math layer to be pure JS with zero wasm boundary crossings?
The serialization gap (34x) is likely harder to address since it's fundamental to the wasm architecture, but for most real apps it's still plenty fast at 17K ops/s as the bottleneck is always network or signing.
RE: Developers' Guide: How Wax Lost Weight 🏋️