diff --git a/.gitignore b/.gitignore index ea8c4bf7..c5df1db2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/target +target +*.wasm diff --git a/Cargo.lock b/Cargo.lock index acd132c4..a2e008fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,6 +28,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + [[package]] name = "anyhow" version = "1.0.61" @@ -372,6 +378,33 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "ciborium" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c137568cc60b904a7724001b35ce2630fd00d5d84805fbb608ab89509d788f" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "346de753af073cc87b52b2083a506b38ac176a44cfb05497b622e27be899b369" + +[[package]] +name = "ciborium-ll" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213030a2b5a4e0c0892b6652260cf6ccac84827b83a85a534e178e3906c4cf1b" +dependencies = [ + "ciborium-io", + "half", +] + [[package]] name = "cipher" version = "0.3.0" @@ -388,10 +421,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "bitflags", - "textwrap", + "textwrap 0.11.0", "unicode-width", ] +[[package]] +name = "clap" +version = "3.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" +dependencies = [ + "bitflags", + "clap_lex", + "indexmap", + "textwrap 0.16.0", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -434,8 +488,8 @@ checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f" dependencies = [ "atty", "cast", - "clap", - "criterion-plot", + "clap 2.34.0", + "criterion-plot 0.4.5", "csv", "itertools", "lazy_static", @@ -452,6 +506,30 @@ dependencies = [ "walkdir", ] +[[package]] +name = "criterion" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c76e09c1aae2bc52b3d2f29e13c6572553b30c4aa1b8a49fd70de6412654cb" +dependencies = [ + "anes", + "atty", + "cast", + "ciborium", + "clap 3.2.23", + "criterion-plot 0.5.0", + "itertools", + "lazy_static", + "num-traits", + "oorandom", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", +] + [[package]] name = "criterion-plot" version = "0.4.5" @@ -462,6 +540,16 @@ dependencies = [ "itertools", ] +[[package]] +name = "criterion-plot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +dependencies = [ + "cast", + "itertools", +] + [[package]] name = "crossbeam-channel" version = "0.5.6" @@ -649,7 +737,7 @@ dependencies = [ "blake2", "blake2b_simd", "borsh", - "criterion", + "criterion 0.3.6", "digest 0.10.3", "ed25519-dalek", "either", @@ -751,7 +839,7 @@ dependencies = [ "ark-std", "blake2b_simd", "chacha20", - "criterion", + "criterion 0.4.0", "hex", "itertools", "miracl_core", @@ -1114,6 +1202,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "os_str_bytes" +version = "6.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3baf96e39c5359d2eb0dd6ccb42c62b91d9678aa68160d261b9e0ccbf9e9dea9" + [[package]] name = "parking_lot" version = "0.11.2" @@ -1190,7 +1284,7 @@ checksum = "55f35f865aa964be21fcde114cbd1cfbd9bf8a471460ed965b0f84f96c711401" dependencies = [ "backtrace", "cfg-if 1.0.0", - "criterion", + "criterion 0.3.6", "findshlibs", "inferno", "lazy_static", @@ -1624,6 +1718,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "textwrap" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" + [[package]] name = "thiserror" version = "1.0.30" diff --git a/ferveo/BENCHMARK.md b/ferveo/BENCHMARK.md new file mode 100644 index 00000000..b17fc2c6 --- /dev/null +++ b/ferveo/BENCHMARK.md @@ -0,0 +1,79 @@ +# WASM results + +``` +TPKE/share_combine: 100 validators threshold 1024*2/3 - #msg 1 - msg-size = 100 bytes + time: [203.07 ms 203.63 ms 204.31 ms] +TPKE/share_combine: 100 validators threshold 2048*2/3 - #msg 1 - msg-size = 100 bytes + time: [202.04 ms 202.49 ms 203.37 ms] +TPKE/share_combine: 100 validators threshold 4096*2/3 - #msg 1 - msg-size = 100 bytes + time: [201.94 ms 202.74 ms 203.32 ms] +TPKE/share_combine: 100 validators threshold 8192*2/3 - #msg 1 - msg-size = 100 bytes + time: [194.89 ms 195.44 ms 196.43 ms] +TPKE/share_combine: 150 validators threshold 1024*2/3 - #msg 1 - msg-size = 100 bytes + time: [291.00 ms 291.93 ms 292.94 ms] +TPKE/share_combine: 150 validators threshold 2048*2/3 - #msg 1 - msg-size = 100 bytes + time: [287.92 ms 291.28 ms 293.63 ms] +TPKE/share_combine: 150 validators threshold 4096*2/3 - #msg 1 - msg-size = 100 bytes + time: [291.20 ms 291.94 ms 292.61 ms] +TPKE/share_combine: 150 validators threshold 8192*2/3 - #msg 1 - msg-size = 100 bytes + time: [292.36 ms 293.98 ms 295.60 ms] +TPKE/share_combine: 200 validators threshold 1024*2/3 - #msg 1 - msg-size = 100 bytes + time: [429.51 ms 431.92 ms 434.20 ms] +TPKE/share_combine: 200 validators threshold 2048*2/3 - #msg 1 - msg-size = 100 bytes + time: [427.99 ms 429.13 ms 430.25 ms] +TPKE/share_combine: 200 validators threshold 4096*2/3 - #msg 1 - msg-size = 100 bytes + time: [428.54 ms 429.52 ms 430.93 ms] +TPKE/share_combine: 200 validators threshold 8192*2/3 - #msg 1 - msg-size = 100 bytes + time: [413.68 ms 426.59 ms 434.22 ms] +``` + +# Rust results +``` +TPKE/share_combine: 100 validators threshold 1024*2/3 - #msg 1 - msg-size = 100 bytes + time: [39.402 ms 39.933 ms 40.442 ms] + change: [-78.967% -78.479% -78.003%] (p = 0.00 < 0.05) +TPKE/share_combine: 100 validators threshold 2048*2/3 - #msg 1 - msg-size = 100 bytes + time: [36.905 ms 37.714 ms 38.555 ms] + change: [-79.026% -78.298% -77.409%] (p = 0.00 < 0.05) + Performance has improved. +TPKE/share_combine: 100 validators threshold 4096*2/3 - #msg 1 - msg-size = 100 bytes + time: [38.335 ms 39.103 ms 40.138 ms] + change: [-79.030% -78.666% -78.289%] (p = 0.00 < 0.05) + Performance has improved. +TPKE/share_combine: 100 validators threshold 8192*2/3 - #msg 1 - msg-size = 100 bytes + time: [37.560 ms 39.477 ms 41.840 ms] + change: [-78.908% -78.079% -77.420%] (p = 0.00 < 0.05) + Performance has improved. +TPKE/share_combine: 150 validators threshold 1024*2/3 - #msg 1 - msg-size = 100 bytes + time: [59.445 ms 60.015 ms 60.918 ms] + change: [-77.813% -77.500% -77.138%] (p = 0.00 < 0.05) + Performance has improved. +TPKE/share_combine: 150 validators threshold 2048*2/3 - #msg 1 - msg-size = 100 bytes + time: [57.400 ms 58.897 ms 59.917 ms] + change: [-79.208% -78.475% -77.800%] (p = 0.00 < 0.05) + Performance has improved. +TPKE/share_combine: 150 validators threshold 4096*2/3 - #msg 1 - msg-size = 100 bytes + time: [55.343 ms 56.937 ms 59.751 ms] + change: [-79.182% -78.302% -77.213%] (p = 0.00 < 0.05) + Performance has improved. +TPKE/share_combine: 150 validators threshold 8192*2/3 - #msg 1 - msg-size = 100 bytes + time: [58.516 ms 59.499 ms 60.542 ms] + change: [-79.088% -78.442% -77.787%] (p = 0.00 < 0.05) + Performance has improved. +TPKE/share_combine: 200 validators threshold 1024*2/3 - #msg 1 - msg-size = 100 bytes + time: [78.889 ms 79.303 ms 79.871 ms] + change: [-79.477% -78.764% -78.196%] (p = 0.00 < 0.05) + Performance has improved. +TPKE/share_combine: 200 validators threshold 2048*2/3 - #msg 1 - msg-size = 100 bytes + time: [78.631 ms 79.323 ms 79.960 ms] + change: [-78.776% -78.250% -77.742%] (p = 0.00 < 0.05) + Performance has improved. +TPKE/share_combine: 200 validators threshold 4096*2/3 - #msg 1 - msg-size = 100 bytes + time: [76.580 ms 77.272 ms 78.058 ms] + change: [-78.700% -78.253% -77.767%] (p = 0.00 < 0.05) + Performance has improved. +TPKE/share_combine: 200 validators threshold 8192*2/3 - #msg 1 - msg-size = 100 bytes + time: [76.676 ms 77.459 ms 78.123 ms] + change: [-80.315% -79.559% -78.876%] (p = 0.00 < 0.05) + Performance has improved. +``` \ No newline at end of file diff --git a/tpke/Cargo.toml b/tpke/Cargo.toml index e22bf8ec..573370e7 100644 --- a/tpke/Cargo.toml +++ b/tpke/Cargo.toml @@ -28,7 +28,7 @@ itertools="0.10" subproductdomain = { path = "../subproductdomain" } [dev-dependencies] -criterion = "0.3" +criterion = { version = "0.4", default-features = false } [[bench]] name = "benchmarks" diff --git a/tpke/README.md b/tpke/README.md new file mode 100644 index 00000000..ae7ffb48 --- /dev/null +++ b/tpke/README.md @@ -0,0 +1,23 @@ +# tpke + +## Benchmarking WASM + +Based on `centurion.rs` (docs)[https://github.com/bheisler/criterion.rs/blob/version-0.4/book/src/user_guide/wasi.md#webasseblywasi-benchmarking] + +### Setup + +```bash +cargo install cargo-wasi +npm install -g @wasmer/cli + +cargo wasi build --bench=benchmarks --release +cp `ls -t ../target/wasm32-wasi/release/deps/*.wasm | head -n 1` benchmarks.wasm +``` + +### Running + +```bash +wasmer-js run --dir=. benchmarks.wasm -- --bench +``` + +### Results