Skip to content

Instantly share code, notes, and snippets.

@jwasinger
jwasinger / Makefile
Last active Jan 7, 2021
Instructions for benchmarking Geth-evm384
View Makefile
all:
clang++ -O3 bench.cpp
@jwasinger
jwasinger / main.cpp
Created Oct 2, 2020
C++ vs Python (uint128)
View main.cpp
#include <stdint.h>
#include <iostream>
int main(int argc, char **argv) {
uint64_t x = 12823323627408599439;
uint64_t y = 5504717096808338412;
__uint128_t res = (__uint128_t)x * y;
std::cout << x << " * " << y << " = " << (uint64_t)res << ", " << (uint64_t)(res >> 64) << std::endl;
@jwasinger
jwasinger / gist:083b59a06ea7c523560b8907b7402689
Created Sep 29, 2020
wasmcurves (with subgroup check) vs wasmsnark (without subgroup check)
View gist:083b59a06ea7c523560b8907b7402689
## wasm-curves:
```
---------------------------------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations UserCounters...
---------------------------------------------------------------------------------------------------------------------
fizzy/parse/main_with_websnark_bignum_hostfuncs 1019 us 1019 us 673 rate=127.256M/s size=129.725k
wabt/parse/main_with_websnark_bignum_hostfuncs 2372 us 2372 us 295 rate=54.6813M/s size=129.725k
wasm3/parse/main_with_websnark_bignum_hostfuncs 75.8 us 75.8 us 9217 rate=1.71145G/s size=129.725k
fizzy/instantiate/main_with_websnark_bignum_hostfuncs 1120 us 1120 us 617
View gist:8d08281ed90b81da16968a452a12d3a5
for i in [0..vec.len]:
vec[i] = vec[i] * vec[i]
return sorted(vec)
@jwasinger
jwasinger / standalone_wasm_results.csv
Created Jun 10, 2020
standalone wasm benchmarks (azure vm) - June 9th 2020
View standalone_wasm_results.csv
We can't make this file beautiful and searchable because it's too large.
engine,test_name,elapsed_time,compile_time,exec_time
wagon,bn128_mul-chfast2,0.20844221115112305,0.069442,0.131921
wagon,bn128_mul-chfast2,0.2028026580810547,0.068059,0.129828
wagon,bn128_mul-chfast2,0.2083592414855957,0.0695,0.134094
wagon,bn128_mul-chfast2,0.20242953300476074,0.067839,0.130541
wagon,bn128_mul-chfast2,0.20944571495056152,0.073585,0.13122
wagon,bn128_mul-chfast2,0.2013232707977295,0.06854,0.128242
wagon,bn128_mul-chfast2,0.21543478965759277,0.075039,0.135703
wagon,bn128_mul-chfast2,0.2297804355621338,0.081116,0.143863
@jwasinger
jwasinger / gist:9e38c1c4d52ac0910bf5a0db64883f3d
Created May 21, 2020
evm384 f6m mul synth loop v2 evm bytecode
View gist:9e38c1c4d52ac0910bf5a0db64883f3d
597fabaafffffffffeb9ffff53b1feffab1e24f6b0f6a0d23067bf1285f3844b776481527fd7ac4b43b6a71b4b9ae67f39ea11011a000000000000000000000000000000006020820152604081017f8f2990f3e598f5b1b8f480a3c388306bc023fac151c0104d13ec3aa18159940281527f72d1c8c528a1ce3bcaa280a8e735aa0d0000000000000000000000000000000060608301527f992d7a27906d4cd530b23a7e8c48c0778f8653fbc3332d63db24339d8bc65d7e60808301527fe83b6e91c6550f5aceab102e88e918090000000000000000000000000000000060a08301527f7299907146816f08c4c6a394e91374ed6ff3618a57358cfb124ee6ab4c560e5c60c08301527fac40700b41e2ee8674680728f0c5a6180000000000000000000000000000000060e08301527f0fd77f62b39eb952a0f8d21cec1f93b1d62dd7923aa86882ddf7dd4d3532b0b76101008301527fede8f3fc89fa4a79574067e2d9a9d200000000000000000000000000000000006101208301527f7a69de46b13d8cb4c4833224aaf9ef7ea6a48975ab35c6e123b8539ab84c381a6101408301527f2533401a73c4e79f47d714899d01ac130000000000000000000000000000000061016083015261018082017fa9fa0b0d8156c36a1a9ddacb73ef278f4d149b560e88789f2bfeb9f708b6cc2f81527f988927bfe0186d5bf9cb40cb
View gist:27ea77111577ac1979d23f0750bde571
debug_printMemHex mem_pos: 288 284544
81f9ab902854e25b9885fd18eedded158d323cd1db63aac85667c846d7b32b2cd8f5fc6051a82f5ad57c039da951ed13d3b0186a84d65f84b496962eb845bf44b964a6dd009f7a9c7b5b31c8838bf7ad0c82c8568e5cba769a9865ef8ee6cc1393f29468d61bae4ee78df89e052fd93155a152b851f91c04e29820e971b2756faea7bb1d8cf88726fd98f26f1e55351464189369f3e2d094567d7159784b51602eaed4b93a96c7eaabdb17e21bc0f4b621ab0d9e6c704a29d07c16f10aa83b1829366951d266201e3461e4c8be6f97735790d8176b661ab62e24ca23a18989ad0b933264a916e4da9b1e8e3ceb7ddf13fc60e840573d9d79559e0c8d1f05e17459fe91066b901c99a515eb21ddfc359590d6ab7ebaec0e58a1d2fbaf0ff5a809
debug_memHex done
debug_printMemHex mem_pos: 288 284832
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008fc2328a6235e95c18abc18596f98a84839e593b9938c3e6ff7e206969e887754424c422d3bfc4dfa3a8f7bb06133119faf9234941983eb86272ccd6aaecab023b073792337fe67897873ade3ea4c5c54
View gist:5c0a292b94e29abb71dc6cadf24192e8
code {
function memcpy_384(dst, src)
{
let hi := mload(src)
let lo := mload(add(src, 32))
mstore(dst, hi)
mstore(add(dst, 32), lo)
}
function f2m_add(x_0, x_1, y_0, y_1, r_0, r_1, modulus)
{
View f6m_mult_pseudocode.yul
function f6m_mul(x_offset, y_offset, ret_offset, mod_offset, inv_offset) {
/*
f6m_mul pseudocode:
a = x_offset[0]
b = x_offset[1]
A = y_offset[0]
B = y_offset[1]
aA = a * A
bB = b * B
View f6m_mul_stub.yul
{
function addmod384(x_offset, y_offset, mod_offset) {
/* stub for future evm opcode */
}
function submod384(x_offset, y_offset, mod_offset) {
/* stub for future evm opcode */
}
function mulmodmont384(x_offset, y_offset, mod_offset, inv_offset) {