From 3ba716054eda713ade351a1854f72f2489186e3b Mon Sep 17 00:00:00 2001 From: Asmir Avdicevic Date: Mon, 6 May 2024 14:34:30 +0200 Subject: [PATCH] cleanup --- Cargo.lock | 646 ++++++++++++++++++++++++++++----- iroh-net/bench/Cargo.toml | 3 +- iroh-net/bench/src/bin/bulk.rs | 14 +- iroh-net/bench/src/iroh.rs | 181 +-------- iroh-net/bench/src/lib.rs | 241 +++++++++--- iroh-net/bench/src/quinn.rs | 312 ++++------------ iroh-net/bench/src/s2n.rs | 3 +- 7 files changed, 825 insertions(+), 575 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9ed7453567..ca146e6e80 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -200,7 +200,7 @@ checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", "synstructure 0.13.1", ] @@ -223,7 +223,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -234,7 +234,7 @@ checksum = "461abc97219de0eaaf81fe3ef974a540158f3d079c2ab200f891f1a2ef201e85" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -246,6 +246,12 @@ dependencies = [ "critical-section", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "attohttpc" version = "0.24.1" @@ -263,6 +269,34 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +[[package]] +name = "aws-lc-rs" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8487b59d62764df8231cb371c459314df895b41756df457a1fb1243d65c89195" +dependencies = [ + "aws-lc-sys", + "mirai-annotations", + "paste", + "untrusted 0.7.1", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c15eb61145320320eb919d9bab524617a7aa4216c78d342fae3a758bc33073e4" +dependencies = [ + "bindgen", + "cc", + "cmake", + "dunce", + "fs_extra", + "libc", + "paste", +] + [[package]] name = "axum" version = "0.7.5" @@ -328,7 +362,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -360,9 +394,9 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b62ddb9cb1ec0a098ad4bbf9344d0713fa193ae1a80af55febcff2627b6a00c1" dependencies = [ - "getrandom", + "getrandom 0.2.14", "instant", - "rand", + "rand 0.8.5", ] [[package]] @@ -445,6 +479,29 @@ dependencies = [ "serde", ] +[[package]] +name = "bindgen" +version = "0.69.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +dependencies = [ + "bitflags 2.5.0", + "cexpr", + "clang-sys", + "itertools", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.60", + "which", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -550,6 +607,19 @@ name = "cc" version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +dependencies = [ + "jobserver", + "libc", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] [[package]] name = "cfg-if" @@ -621,6 +691,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "clang-sys" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" version = "4.5.4" @@ -652,7 +733,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -672,6 +753,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + [[package]] name = "cobs" version = "0.2.3" @@ -911,7 +1001,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", - "rand_core", + "rand_core 0.6.4", "subtle", "zeroize", ] @@ -923,7 +1013,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", - "rand_core", + "rand_core 0.6.4", "typenum", ] @@ -959,6 +1049,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "cuckoofilter" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b810a8449931679f64cd7eef1bbd0fa315801b6d5d9cdc1ace2804d6529eee18" +dependencies = [ + "byteorder", + "fnv", + "rand 0.7.3", +] + [[package]] name = "curve25519-dalek" version = "4.1.2" @@ -984,7 +1085,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -1008,7 +1109,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -1019,7 +1120,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -1105,7 +1206,7 @@ checksum = "5fe87ce4529967e0ba1dcf8450bab64d97dfd5010a6256187ffe2e43e6f0e049" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -1135,7 +1236,7 @@ checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", "unicode-xid", ] @@ -1218,7 +1319,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -1250,6 +1351,12 @@ dependencies = [ "shared_child", ] +[[package]] +name = "dunce" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" + [[package]] name = "ecdsa" version = "0.16.9" @@ -1283,7 +1390,7 @@ checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ "curve25519-dalek", "ed25519", - "rand_core", + "rand_core 0.6.4", "serde", "sha2", "subtle", @@ -1321,7 +1428,7 @@ dependencies = [ "generic-array", "group", "pkcs8", - "rand_core", + "rand_core 0.6.4", "sec1", "subtle", "zeroize", @@ -1363,7 +1470,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -1376,7 +1483,7 @@ dependencies = [ "num-traits", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -1396,7 +1503,7 @@ checksum = "5c785274071b1b420972453b306eeca06acf4633829db4223b58a2a8c5953bc4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -1480,7 +1587,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -1527,6 +1634,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "futures" version = "0.3.30" @@ -1607,7 +1720,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -1688,6 +1801,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + [[package]] name = "getrandom" version = "0.2.14" @@ -1697,7 +1821,7 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "wasm-bindgen", ] @@ -1728,7 +1852,7 @@ dependencies = [ "parking_lot", "portable-atomic", "quanta", - "rand", + "rand 0.8.5", "smallvec", "spinning_top", ] @@ -1740,7 +1864,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -1801,6 +1925,12 @@ dependencies = [ "byteorder", ] +[[package]] +name = "hash_hasher" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74721d007512d0cb3338cd20f0654ac913920061a4c4d0d8708edb3f2a698c0c" + [[package]] name = "hashbrown" version = "0.12.3" @@ -1874,6 +2004,12 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + [[package]] name = "hickory-proto" version = "0.24.1" @@ -1890,7 +2026,7 @@ dependencies = [ "idna 0.4.0", "ipnet", "once_cell", - "rand", + "rand 0.8.5", "ring 0.16.20", "rustls", "rustls-pemfile 1.0.4", @@ -1916,7 +2052,7 @@ dependencies = [ "lru-cache", "once_cell", "parking_lot", - "rand", + "rand 0.8.5", "resolv-conf", "rustls", "serde", @@ -2225,7 +2361,7 @@ dependencies = [ "http 0.2.12", "hyper 0.14.28", "log", - "rand", + "rand 0.8.5", "tokio", "url", "xmltree", @@ -2294,6 +2430,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "intrusive-collections" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b694dc9f70c3bda874626d2aed13b780f137aab435f4e9814121955cf706122e" +dependencies = [ + "memoffset", +] + [[package]] name = "ipconfig" version = "0.3.2" @@ -2344,8 +2489,8 @@ dependencies = [ "proptest", "quic-rpc", "quinn", - "rand", - "rand_chacha", + "rand 0.8.5", + "rand_chacha 0.3.1", "regex", "serde", "serde_json", @@ -2377,8 +2522,8 @@ dependencies = [ "once_cell", "postcard", "proptest", - "rand", - "rand_core", + "rand 0.8.5", + "rand_core 0.6.4", "redb 2.1.0", "serde", "serde-error", @@ -2432,7 +2577,7 @@ dependencies = [ "postcard", "proptest", "quinn", - "rand", + "rand 0.8.5", "range-collections", "rcgen 0.12.1", "redb 1.5.1", @@ -2482,7 +2627,7 @@ dependencies = [ "postcard", "quic-rpc", "quinn", - "rand", + "rand 0.8.5", "regex", "rustyline", "serde", @@ -2570,9 +2715,9 @@ dependencies = [ "iroh-test", "postcard", "quinn", - "rand", - "rand_chacha", - "rand_core", + "rand 0.8.5", + "rand_chacha 0.3.1", + "rand_core 0.6.4", "serde", "tokio", "tokio-util", @@ -2662,9 +2807,9 @@ dependencies = [ "quinn", "quinn-proto", "quinn-udp", - "rand", - "rand_chacha", - "rand_core", + "rand 0.8.5", + "rand_chacha 0.3.1", + "rand_core 0.6.4", "rcgen 0.11.3", "regex", "reqwest", @@ -2702,7 +2847,7 @@ dependencies = [ [[package]] name = "iroh-net-bench" -version = "0.13.0" +version = "0.15.0" dependencies = [ "anyhow", "bytes", @@ -2712,6 +2857,7 @@ dependencies = [ "quinn", "rcgen 0.11.3", "rustls", + "s2n-quic", "socket2", "tokio", "tracing", @@ -2739,9 +2885,9 @@ dependencies = [ "postcard", "proptest", "quinn", - "rand", - "rand_chacha", - "rand_core", + "rand 0.8.5", + "rand_chacha 0.3.1", + "rand_core 0.6.4", "redb 1.5.1", "redb 2.1.0", "self_cell", @@ -2792,6 +2938,15 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "jobserver" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.69" @@ -2810,12 +2965,28 @@ dependencies = [ "spin 0.5.2", ] +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "libloading" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" +dependencies = [ + "cfg-if", + "windows-targets 0.52.5", +] + [[package]] name = "libm" version = "0.2.8" @@ -2889,7 +3060,7 @@ dependencies = [ "ed25519-dalek", "flume", "lru", - "rand", + "rand 0.8.5", "serde", "serde_bencode", "serde_bytes", @@ -2937,6 +3108,15 @@ version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + [[package]] name = "mime" version = "0.3.17" @@ -2965,17 +3145,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.48.0", ] +[[package]] +name = "mirai-annotations" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1" + [[package]] name = "nanorand" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" dependencies = [ - "getrandom", + "getrandom 0.2.14", ] [[package]] @@ -3183,7 +3369,7 @@ dependencies = [ "num-integer", "num-iter", "num-traits", - "rand", + "rand 0.8.5", "smallvec", "zeroize", ] @@ -3214,6 +3400,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.18" @@ -3252,7 +3449,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -3377,7 +3574,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "primeorder", - "rand_core", + "rand_core 0.6.4", "sha2", ] @@ -3472,7 +3669,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -3503,7 +3700,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -3527,7 +3724,7 @@ dependencies = [ "bytes", "ed25519-dalek", "mainline", - "rand", + "rand 0.8.5", "reqwest", "self_cell", "simple-dns", @@ -3609,7 +3806,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -3741,6 +3938,16 @@ dependencies = [ "yansi", ] +[[package]] +name = "prettyplease" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ac2cf0f2e4f42b49f5ffd07dae8d746508ef7526c13940e5f524012ae6c6550" +dependencies = [ + "proc-macro2", + "syn 2.0.60", +] + [[package]] name = "primeorder" version = "0.13.6" @@ -3820,7 +4027,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -3834,8 +4041,8 @@ dependencies = [ "bitflags 2.5.0", "lazy_static", "num-traits", - "rand", - "rand_chacha", + "rand 0.8.5", + "rand_chacha 0.3.1", "rand_xorshift", "regex-syntax 0.8.3", "rusty-fork", @@ -3853,7 +4060,7 @@ dependencies = [ "libc", "once_cell", "raw-cpuid", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "web-sys", "winapi", ] @@ -3909,7 +4116,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "141bf7dfde2fbc246bfd3fe12f2455aa24b0fbd9af535d8c86c7bd1381ff2b1a" dependencies = [ "bytes", - "rand", + "rand 0.8.5", "ring 0.16.20", "rustc-hash", "rustls", @@ -3962,6 +4169,19 @@ dependencies = [ "nibble_vec", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + [[package]] name = "rand" version = "0.8.5" @@ -3969,8 +4189,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", ] [[package]] @@ -3980,7 +4210,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", ] [[package]] @@ -3989,7 +4228,16 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.14", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", ] [[package]] @@ -3998,7 +4246,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" dependencies = [ - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -4108,7 +4356,7 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ - "getrandom", + "getrandom 0.2.14", "libredox", "thiserror", ] @@ -4130,7 +4378,7 @@ checksum = "5fddb4f8d99b0a2ebafc65a87a69a7b9875e4b1ae1f00db265d300ef7f28bccc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -4278,7 +4526,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom", + "getrandom 0.2.14", "libc", "spin 0.9.8", "untrusted 0.9.0", @@ -4298,7 +4546,7 @@ dependencies = [ "num-traits", "pkcs1", "pkcs8", - "rand_core", + "rand_core 0.6.4", "sha2", "signature", "spki", @@ -4473,6 +4721,173 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +[[package]] +name = "s2n-codec" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43c1a1c2ffb3dc6f12c6185d7ad349608eb9aea4855c2009527e8784cd51bddb" +dependencies = [ + "byteorder", + "bytes", + "zerocopy", +] + +[[package]] +name = "s2n-quic" +version = "1.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d556469ff8f4e0e27cddf6ac1065cedafe2216460ce934d77e1ab6e8244f8e1e" +dependencies = [ + "bytes", + "cfg-if", + "cuckoofilter", + "futures", + "hash_hasher", + "rand 0.8.5", + "rand_chacha 0.3.1", + "s2n-codec", + "s2n-quic-core", + "s2n-quic-crypto", + "s2n-quic-platform", + "s2n-quic-tls-default", + "s2n-quic-transport", + "tokio", + "zerocopy", + "zeroize", +] + +[[package]] +name = "s2n-quic-core" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98d874d608d0e9fa2ea207a6288e1d6926c847b37c777cadae9037c24175e798" +dependencies = [ + "atomic-waker", + "byteorder", + "bytes", + "cfg-if", + "crossbeam-utils", + "hex-literal", + "num-rational", + "num-traits", + "once_cell", + "pin-project-lite", + "s2n-codec", + "subtle", + "zerocopy", +] + +[[package]] +name = "s2n-quic-crypto" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a1bab1f520dca4e26d81491c9177dc6f3aeb9289c0a8ccc64c24ea3ca178de7" +dependencies = [ + "aws-lc-rs", + "cfg-if", + "lazy_static", + "ring 0.16.20", + "s2n-codec", + "s2n-quic-core", + "zeroize", +] + +[[package]] +name = "s2n-quic-platform" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97f554fdd14e0859b37ce321ec02ce65ad9be58dd13edc7ef1b48fd0e9b4a0d3" +dependencies = [ + "cfg-if", + "futures", + "lazy_static", + "libc", + "s2n-quic-core", + "socket2", + "tokio", +] + +[[package]] +name = "s2n-quic-rustls" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6dcc2248b915dde6d4582940e2cddf1159daa38763d2a850ccd2d2864ab8e7a" +dependencies = [ + "bytes", + "rustls", + "rustls-pemfile 1.0.4", + "s2n-codec", + "s2n-quic-core", + "s2n-quic-crypto", +] + +[[package]] +name = "s2n-quic-tls" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "619c244acd675c14bed8395a09c914b4e9ac47718b74e76fa3ae5f4de44c302f" +dependencies = [ + "bytes", + "errno", + "libc", + "s2n-codec", + "s2n-quic-core", + "s2n-quic-crypto", + "s2n-tls", +] + +[[package]] +name = "s2n-quic-tls-default" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c558abeb3aee9c92715dd9993ce25398c0ffd7a7f039b7c860bf3b7966d9e3" +dependencies = [ + "s2n-quic-rustls", + "s2n-quic-tls", +] + +[[package]] +name = "s2n-quic-transport" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4f03d79bed78230473bced1db82b7778c0d7c605b1f90b23fa02dddc12f2dc3" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "hashbrown 0.14.3", + "intrusive-collections", + "once_cell", + "s2n-codec", + "s2n-quic-core", + "siphasher", + "smallvec", +] + +[[package]] +name = "s2n-tls" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8b989c13b04b7e23c0161e5f18f16c7efaa06f86d7647df4b469bbce43e1a63" +dependencies = [ + "errno", + "hex", + "libc", + "pin-project-lite", + "s2n-tls-sys", +] + +[[package]] +name = "s2n-tls-sys" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58db90b89847b170999d01e95fe37f059af038d1c4f8609adc64a5241a2d99d" +dependencies = [ + "aws-lc-rs", + "cc", + "libc", +] + [[package]] name = "salsa20" version = "0.10.2" @@ -4613,7 +5028,7 @@ checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -4694,7 +5109,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -4769,6 +5184,12 @@ dependencies = [ "dirs", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -4785,7 +5206,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest", - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -4797,6 +5218,12 @@ dependencies = [ "bitflags 2.5.0", ] +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "slab" version = "0.4.9" @@ -4890,7 +5317,7 @@ dependencies = [ "p256", "p384", "p521", - "rand_core", + "rand_core 0.6.4", "rsa", "sec1", "sha2", @@ -4945,7 +5372,7 @@ dependencies = [ "proc-macro2", "quote", "struct_iterable_internal", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -4963,7 +5390,7 @@ dependencies = [ "proc-macro2", "quote", "structmeta-derive", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -4974,7 +5401,7 @@ checksum = "a60bcaff7397072dca0017d1db428e30d5002e00b6847703e2e42005c95fbe00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -5005,7 +5432,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -5018,7 +5445,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -5042,7 +5469,7 @@ dependencies = [ "precis-core", "precis-profiles", "quoted-string-parser", - "rand", + "rand 0.8.5", ] [[package]] @@ -5060,7 +5487,7 @@ dependencies = [ "hex", "parking_lot", "pnet_packet", - "rand", + "rand 0.8.5", "socket2", "thiserror", "tokio", @@ -5080,9 +5507,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.53" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -5132,7 +5559,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -5191,7 +5618,7 @@ dependencies = [ "proc-macro2", "quote", "structmeta", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -5225,7 +5652,7 @@ checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -5323,7 +5750,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -5548,7 +5975,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -5762,6 +6189,12 @@ dependencies = [ "try-lock", ] +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -5795,7 +6228,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", "wasm-bindgen-shared", ] @@ -5829,7 +6262,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5868,6 +6301,18 @@ version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + [[package]] name = "whoami" version = "1.5.1" @@ -5995,7 +6440,7 @@ checksum = "12168c33176773b86799be25e2a2ba07c7aab9968b37541f1094dbd7a60c8946" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -6006,7 +6451,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -6017,7 +6462,7 @@ checksum = "9d8dc32e0095a7eeccebd0e3f09e9509365ecb3fc6ac4d6f5f14a3f6392942d1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -6028,7 +6473,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -6297,6 +6742,7 @@ version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ + "byteorder", "zerocopy-derive", ] @@ -6308,7 +6754,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.60", ] [[package]] @@ -6316,3 +6762,17 @@ name = "zeroize" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] diff --git a/iroh-net/bench/Cargo.toml b/iroh-net/bench/Cargo.toml index f1ce242862..e178b829ae 100644 --- a/iroh-net/bench/Cargo.toml +++ b/iroh-net/bench/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iroh-net-bench" -version = "0.13.0" +version = "0.15.0" edition = "2021" license = "MIT OR Apache-2.0" publish = false @@ -17,4 +17,5 @@ clap = { version = "4", features = ["derive"] } tokio = { version = "1.0.1", features = ["rt", "sync"] } tracing = "0.1" tracing-subscriber = { version = "0.3.0", default-features = false, features = ["env-filter", "fmt", "ansi", "time", "local-time"] } +s2n-quic = "1.37.0" socket2 = "0.5" \ No newline at end of file diff --git a/iroh-net/bench/src/bin/bulk.rs b/iroh-net/bench/src/bin/bulk.rs index cd7bc2cc17..87311ef46f 100644 --- a/iroh-net/bench/src/bin/bulk.rs +++ b/iroh-net/bench/src/bin/bulk.rs @@ -2,7 +2,7 @@ use anyhow::Result; use clap::Parser; use iroh_net_bench::{ - configure_tracing_subscriber, iroh, rt, Commands, quinn, s2n, + configure_tracing_subscriber, iroh, quinn, rt, s2n, server, Commands, Endpoint, Opt, }; fn main() { @@ -28,7 +28,7 @@ fn main() { } } -pub fn run_iroh(opt: iroh::Opt) -> Result<()> { +pub fn run_iroh(opt: Opt) -> Result<()> { let server_span = tracing::error_span!("server"); let runtime = rt(); let (server_addr, endpoint) = { @@ -38,7 +38,7 @@ pub fn run_iroh(opt: iroh::Opt) -> Result<()> { let server_thread = std::thread::spawn(move || { let _guard = server_span.entered(); - if let Err(e) = runtime.block_on(iroh::server(endpoint, opt)) { + if let Err(e) = runtime.block_on(server(Endpoint::Iroh(endpoint), opt)) { eprintln!("server failed: {e:#}"); } }); @@ -72,7 +72,7 @@ pub fn run_iroh(opt: iroh::Opt) -> Result<()> { Ok(()) } -pub fn run_quinn(opt: quinn::Opt) -> Result<()> { +pub fn run_quinn(opt: Opt) -> Result<()> { let server_span = tracing::error_span!("server"); let runtime = rt(); let (server_addr, endpoint) = { @@ -82,7 +82,7 @@ pub fn run_quinn(opt: quinn::Opt) -> Result<()> { let server_thread = std::thread::spawn(move || { let _guard = server_span.entered(); - if let Err(e) = runtime.block_on(quinn::server(endpoint, opt)) { + if let Err(e) = runtime.block_on(server(Endpoint::Quinn(endpoint), opt)) { eprintln!("server failed: {e:#}"); } }); @@ -117,5 +117,5 @@ pub fn run_quinn(opt: quinn::Opt) -> Result<()> { } pub fn run_s2n(_opt: s2n::Opt) -> Result<()> { - Ok(()) -} \ No newline at end of file + unimplemented!() +} diff --git a/iroh-net/bench/src/iroh.rs b/iroh-net/bench/src/iroh.rs index 56f6840453..8f90568931 100644 --- a/iroh-net/bench/src/iroh.rs +++ b/iroh-net/bench/src/iroh.rs @@ -1,50 +1,13 @@ -use std::{net::SocketAddr, sync::{Arc, Mutex}, time::Instant}; +use std::net::SocketAddr; use anyhow::{Context, Result}; -use clap::Parser; use iroh_net::{relay::RelayMode, MagicEndpoint, NodeAddr}; -use tokio::sync::Semaphore; -use tracing::{info, trace}; +use tracing::trace; -use crate::{drain_stream, handle_client_stream, parse_byte_size, send_data_on_stream, stats::TransferResult, ClientStats}; +use crate::{client_handler, transport_config, ClientStats, Endpoint, Opt}; pub const ALPN: &[u8] = b"n0/iroh-net-bench/0"; -#[derive(Parser, Debug, Clone, Copy)] -#[clap(name = "iroh")] -pub struct Opt { - /// The total number of clients which should be created - #[clap(long = "clients", short = 'c', default_value = "1")] - pub clients: usize, - /// The total number of streams which should be created - #[clap(long = "streams", short = 'n', default_value = "1")] - pub streams: usize, - /// The amount of concurrent streams which should be used - #[clap(long = "max_streams", short = 'm', default_value = "1")] - pub max_streams: usize, - /// Number of bytes to transmit from server to client - /// - /// This can use SI prefixes for sizes. E.g. 1M will transfer 1MiB, 10G - /// will transfer 10GiB. - #[clap(long, default_value = "1G", value_parser = parse_byte_size)] - pub download_size: u64, - /// Number of bytes to transmit from client to server - /// - /// This can use SI prefixes for sizes. E.g. 1M will transfer 1MiB, 10G - /// will transfer 10GiB. - #[clap(long, default_value = "0", value_parser = parse_byte_size)] - pub upload_size: u64, - /// Show connection stats the at the end of the benchmark - #[clap(long = "stats")] - pub stats: bool, - /// Whether to use the unordered read API - #[clap(long = "unordered")] - pub read_unordered: bool, - /// Starting guess for maximum UDP payload size - #[clap(long, default_value = "1200")] - pub initial_mtu: u16, -} - /// Creates a server endpoint which runs on the given runtime pub fn server_endpoint(rt: &tokio::runtime::Runtime, opt: &Opt) -> (NodeAddr, MagicEndpoint) { let _guard = rt.enter(); @@ -52,7 +15,7 @@ pub fn server_endpoint(rt: &tokio::runtime::Runtime, opt: &Opt) -> (NodeAddr, Ma let ep = MagicEndpoint::builder() .alpns(vec![ALPN.to_vec()]) .relay_mode(RelayMode::Disabled) - .transport_config(transport_config(opt)) + .transport_config(transport_config(opt.max_streams, opt.initial_mtu)) .bind(0) .await .unwrap(); @@ -63,6 +26,12 @@ pub fn server_endpoint(rt: &tokio::runtime::Runtime, opt: &Opt) -> (NodeAddr, Ma }) } +/// Create and run a client +pub async fn client(server_addr: NodeAddr, opt: Opt) -> Result { + let (endpoint, connection) = connect_client(server_addr, opt).await?; + client_handler(Endpoint::Iroh(endpoint), connection, opt).await +} + /// Create a client endpoint and client connection pub async fn connect_client( server_addr: NodeAddr, @@ -71,7 +40,7 @@ pub async fn connect_client( let endpoint = MagicEndpoint::builder() .alpns(vec![ALPN.to_vec()]) .relay_mode(RelayMode::Disabled) - .transport_config(transport_config(&opt)) + .transport_config(transport_config(opt.max_streams, opt.initial_mtu)) .bind(0) .await .unwrap(); @@ -88,131 +57,3 @@ pub async fn connect_client( Ok((endpoint, connection)) } - -pub fn transport_config(opt: &Opt) -> quinn::TransportConfig { - // High stream windows are chosen because the amount of concurrent streams - // is configurable as a parameter. - let mut config = quinn::TransportConfig::default(); - config.max_concurrent_uni_streams(opt.max_streams.try_into().unwrap()); - config.initial_mtu(opt.initial_mtu); - - // TODO: reenable when we upgrade quinn version - // let mut acks = quinn::AckFrequencyConfig::default(); - // acks.ack_eliciting_threshold(10u32.into()); - // config.ack_frequency_config(Some(acks)); - - config -} - - - - - - - - - -pub async fn server(endpoint: MagicEndpoint, opt: Opt) -> Result<()> { - let mut server_tasks = Vec::new(); - - // Handle only the expected amount of clients - for _ in 0..opt.clients { - let handshake = endpoint.accept().await.unwrap(); - let connection = handshake.await.context("handshake failed")?; - - server_tasks.push(tokio::spawn(async move { - loop { - let (mut send_stream, mut recv_stream) = match connection.accept_bi().await { - Err(quinn::ConnectionError::ApplicationClosed(_)) => break, - Err(e) => { - eprintln!("accepting stream failed: {e:?}"); - break; - } - Ok(stream) => stream, - }; - trace!("stream established"); - - tokio::spawn(async move { - drain_stream(&mut recv_stream, opt.read_unordered).await?; - send_data_on_stream(&mut send_stream, opt.download_size).await?; - Ok::<_, anyhow::Error>(()) - }); - } - - if opt.stats { - println!("\nServer connection stats:\n{:#?}", connection.stats()); - } - })); - } - - // Await all the tasks. We have to do this to prevent the runtime getting dropped - // and all server tasks to be cancelled - for handle in server_tasks { - if let Err(e) = handle.await { - eprintln!("Server task error: {e:?}"); - }; - } - - Ok(()) -} - -pub async fn client(server_addr: NodeAddr, opt: Opt) -> Result { - let (endpoint, connection) = connect_client(server_addr, opt).await?; - - let start = Instant::now(); - - let connection = Arc::new(connection); - - let mut stats = ClientStats::default(); - let mut first_error = None; - - let sem = Arc::new(Semaphore::new(opt.max_streams)); - let results = Arc::new(Mutex::new(Vec::new())); - for _ in 0..opt.streams { - let permit = sem.clone().acquire_owned().await.unwrap(); - let results = results.clone(); - let connection = connection.clone(); - tokio::spawn(async move { - let result = - handle_client_stream(connection, opt.upload_size, opt.read_unordered).await; - info!("stream finished: {:?}", result); - results.lock().unwrap().push(result); - drop(permit); - }); - } - - // Wait for remaining streams to finish - let _ = sem.acquire_many(opt.max_streams as u32).await.unwrap(); - - for result in results.lock().unwrap().drain(..) { - match result { - Ok((upload_result, download_result)) => { - stats.upload_stats.stream_finished(upload_result); - stats.download_stats.stream_finished(download_result); - } - Err(e) => { - if first_error.is_none() { - first_error = Some(e); - } - } - } - } - - stats.upload_stats.total_duration = start.elapsed(); - stats.download_stats.total_duration = start.elapsed(); - - // Explicit close of the connection, since handles can still be around due - // to `Arc`ing them - connection.close(0u32.into(), b"Benchmark done"); - - endpoint.close(0u32.into(), b"").await?; - - if opt.stats { - println!("\nClient connection stats:\n{:#?}", connection.stats()); - } - - match first_error { - None => Ok(stats), - Some(e) => Err(e), - } -} diff --git a/iroh-net/bench/src/lib.rs b/iroh-net/bench/src/lib.rs index 43c8fd54f9..01743ab008 100644 --- a/iroh-net/bench/src/lib.rs +++ b/iroh-net/bench/src/lib.rs @@ -1,13 +1,18 @@ -use std::{net::SocketAddr, num::ParseIntError, str::FromStr, sync::Arc, time::Instant}; - +use std::{ + num::ParseIntError, + str::FromStr, + sync::{Arc, Mutex}, + time::Instant, +}; + +use ::quinn::{Connection, RecvStream, SendStream, TransportConfig}; use anyhow::{Context, Result}; use bytes::Bytes; use clap::Parser; -use ::quinn::{Connection, RecvStream, SendStream}; -use socket2::{Domain, Protocol, Socket, Type}; use stats::{Stats, TransferResult}; use tokio::runtime::{Builder, Runtime}; -use tracing::warn; +use tokio::sync::Semaphore; +use tracing::{info, trace}; pub mod iroh; pub mod quinn; @@ -17,11 +22,51 @@ pub mod stats; #[derive(Parser, Debug, Clone, Copy)] #[clap(name = "bulk")] pub enum Commands { - Iroh(iroh::Opt), - Quinn(quinn::Opt), + Iroh(Opt), + Quinn(Opt), S2n(s2n::Opt), } +#[derive(Parser, Debug, Clone, Copy)] +#[clap(name = "options")] +pub struct Opt { + /// The total number of clients which should be created + #[clap(long = "clients", short = 'c', default_value = "1")] + pub clients: usize, + /// The total number of streams which should be created + #[clap(long = "streams", short = 'n', default_value = "1")] + pub streams: usize, + /// The amount of concurrent streams which should be used + #[clap(long = "max_streams", short = 'm', default_value = "1")] + pub max_streams: usize, + /// Number of bytes to transmit from server to client + /// + /// This can use SI prefixes for sizes. E.g. 1M will transfer 1MiB, 10G + /// will transfer 10GiB. + #[clap(long, default_value = "1G", value_parser = parse_byte_size)] + pub download_size: u64, + /// Number of bytes to transmit from client to server + /// + /// This can use SI prefixes for sizes. E.g. 1M will transfer 1MiB, 10G + /// will transfer 10GiB. + #[clap(long, default_value = "0", value_parser = parse_byte_size)] + pub upload_size: u64, + /// Show connection stats the at the end of the benchmark + #[clap(long = "stats")] + pub stats: bool, + /// Whether to use the unordered read API + #[clap(long = "unordered")] + pub read_unordered: bool, + /// Starting guess for maximum UDP payload size + #[clap(long, default_value = "1200")] + pub initial_mtu: u16, +} + +pub enum Endpoint { + Iroh(iroh_net::MagicEndpoint), + Quinn(::quinn::Endpoint), +} + pub fn configure_tracing_subscriber() { tracing::subscriber::set_global_default( tracing_subscriber::FmtSubscriber::builder() @@ -78,48 +123,7 @@ impl ClientStats { } } -pub fn bind_socket( - addr: SocketAddr, - send_buffer_size: usize, - recv_buffer_size: usize, -) -> Result { - let socket = Socket::new(Domain::for_address(addr), Type::DGRAM, Some(Protocol::UDP)) - .context("create socket")?; - - if addr.is_ipv6() { - socket.set_only_v6(false).context("set_only_v6")?; - } - - socket - .bind(&socket2::SockAddr::from(addr)) - .context("binding endpoint")?; - socket - .set_send_buffer_size(send_buffer_size) - .context("send buffer size")?; - socket - .set_recv_buffer_size(recv_buffer_size) - .context("recv buffer size")?; - - let buf_size = socket.send_buffer_size().context("send buffer size")?; - if buf_size < send_buffer_size { - warn!( - "Unable to set desired send buffer size. Desired: {}, Actual: {}", - send_buffer_size, buf_size - ); - } - - let buf_size = socket.recv_buffer_size().context("recv buffer size")?; - if buf_size < recv_buffer_size { - warn!( - "Unable to set desired recv buffer size. Desired: {}, Actual: {}", - recv_buffer_size, buf_size - ); - } - - Ok(socket.into()) -} - -pub async fn drain_stream(stream: &mut RecvStream, read_unordered: bool) -> Result { +async fn drain_stream(stream: &mut RecvStream, read_unordered: bool) -> Result { let mut read = 0; if read_unordered { @@ -148,7 +152,7 @@ pub async fn drain_stream(stream: &mut RecvStream, read_unordered: bool) -> Resu Ok(read) } -pub async fn send_data_on_stream(stream: &mut SendStream, stream_size: u64) -> Result<()> { +async fn send_data_on_stream(stream: &mut SendStream, stream_size: u64) -> Result<()> { const DATA: &[u8] = &[0xAB; 1024 * 1024]; let bytes_data = Bytes::from_static(DATA); @@ -174,7 +178,6 @@ pub async fn send_data_on_stream(stream: &mut SendStream, stream_size: u64) -> R Ok(()) } - async fn handle_client_stream( connection: Arc, upload_size: u64, @@ -196,4 +199,138 @@ async fn handle_client_stream( let download_result = TransferResult::new(start.elapsed(), size as u64); Ok((upload_result, download_result)) -} \ No newline at end of file +} + +pub fn transport_config(max_streams: usize, initial_mtu: u16) -> TransportConfig { + // High stream windows are chosen because the amount of concurrent streams + // is configurable as a parameter. + let mut config = TransportConfig::default(); + config.max_concurrent_uni_streams(max_streams.try_into().unwrap()); + config.initial_mtu(initial_mtu); + + // TODO: reenable when we upgrade quinn version + // let mut acks = quinn::AckFrequencyConfig::default(); + // acks.ack_eliciting_threshold(10u32.into()); + // config.ack_frequency_config(Some(acks)); + + config +} + +/// Take the provided endpoint and run the server +pub async fn server(endpoint: Endpoint, opt: Opt) -> Result<()> { + let mut server_tasks = Vec::new(); + + // Handle only the expected amount of clients + for _ in 0..opt.clients { + let handshake = match endpoint { + Endpoint::Iroh(ref endpoint) => endpoint.accept().await.unwrap(), + Endpoint::Quinn(ref endpoint) => endpoint.accept().await.unwrap(), + }; + let connection = handshake.await.context("handshake failed")?; + + server_tasks.push(tokio::spawn(async move { + loop { + let (mut send_stream, mut recv_stream) = match connection.accept_bi().await { + Err(::quinn::ConnectionError::ApplicationClosed(_)) => break, + Err(e) => { + eprintln!("accepting stream failed: {e:?}"); + break; + } + Ok(stream) => stream, + }; + trace!("stream established"); + + tokio::spawn(async move { + drain_stream(&mut recv_stream, opt.read_unordered).await?; + send_data_on_stream(&mut send_stream, opt.download_size).await?; + Ok::<_, anyhow::Error>(()) + }); + } + + if opt.stats { + println!("\nServer connection stats:\n{:#?}", connection.stats()); + } + })); + } + + // Await all the tasks. We have to do this to prevent the runtime getting dropped + // and all server tasks to be cancelled + for handle in server_tasks { + if let Err(e) = handle.await { + eprintln!("Server task error: {e:?}"); + }; + } + + Ok(()) +} + +/// Take the provided endpoint and run the client benchmark +pub async fn client_handler( + endpoint: Endpoint, + connection: ::quinn::Connection, + opt: Opt, +) -> Result { + let start = Instant::now(); + + let connection = Arc::new(connection); + + let mut stats = ClientStats::default(); + let mut first_error = None; + + let sem = Arc::new(Semaphore::new(opt.max_streams)); + let results = Arc::new(Mutex::new(Vec::new())); + for _ in 0..opt.streams { + let permit = sem.clone().acquire_owned().await.unwrap(); + let results = results.clone(); + let connection = connection.clone(); + tokio::spawn(async move { + let result = + handle_client_stream(connection, opt.upload_size, opt.read_unordered).await; + info!("stream finished: {:?}", result); + results.lock().unwrap().push(result); + drop(permit); + }); + } + + // Wait for remaining streams to finish + let _ = sem.acquire_many(opt.max_streams as u32).await.unwrap(); + + for result in results.lock().unwrap().drain(..) { + match result { + Ok((upload_result, download_result)) => { + stats.upload_stats.stream_finished(upload_result); + stats.download_stats.stream_finished(download_result); + } + Err(e) => { + if first_error.is_none() { + first_error = Some(e); + } + } + } + } + + stats.upload_stats.total_duration = start.elapsed(); + stats.download_stats.total_duration = start.elapsed(); + + // Explicit close of the connection, since handles can still be around due + // to `Arc`ing them + connection.close(0u32.into(), b"Benchmark done"); + + match endpoint { + Endpoint::Iroh(endpoint) => { + endpoint.close(0u32.into(), b"").await?; + } + Endpoint::Quinn(endpoint) => { + endpoint.close(0u32.into(), b""); + } + } + + if opt.stats { + println!("\nClient connection stats:\n{:#?}", connection.stats()); + } + + match first_error { + None => Ok(stats), + Some(e) => Err(e), + } +} diff --git a/iroh-net/bench/src/quinn.rs b/iroh-net/bench/src/quinn.rs index 79a9ae6d0a..73a8bd8968 100644 --- a/iroh-net/bench/src/quinn.rs +++ b/iroh-net/bench/src/quinn.rs @@ -1,85 +1,30 @@ -use std::{net::SocketAddr, sync::{Arc, Mutex}, time::Instant}; +use std::{net::SocketAddr, sync::Arc}; use anyhow::{Context, Result}; -use clap::Parser; -use quinn::{Connection, Endpoint, TokioRuntime}; -use tokio::sync::Semaphore; -use tracing::{info, trace}; +use quinn::{Connection, TokioRuntime}; +use socket2::{Domain, Protocol, Socket, Type}; +use tracing::warn; -use crate::{bind_socket, drain_stream, handle_client_stream, parse_byte_size, send_data_on_stream, ClientStats}; +use crate::{client_handler, transport_config, ClientStats, Endpoint, Opt}; +/// Derived from the iroh-net udp SOCKET_BUFFER_SIZE +const SOCKET_BUFFER_SIZE: usize = 7 << 20; pub const ALPN: &[u8] = b"n0/quinn-bench/0"; -#[derive(Parser, Debug, Clone, Copy)] -#[clap(name = "quinn")] -pub struct Opt { - /// The total number of clients which should be created - #[clap(long = "clients", short = 'c', default_value = "1")] - pub clients: usize, - /// The total number of streams which should be created - #[clap(long = "streams", short = 'n', default_value = "1")] - pub streams: usize, - /// The amount of concurrent streams which should be used - #[clap(long = "max_streams", short = 'm', default_value = "1")] - pub max_streams: usize, - /// Number of bytes to transmit from server to client - /// - /// This can use SI prefixes for sizes. E.g. 1M will transfer 1MiB, 10G - /// will transfer 10GiB. - #[clap(long, default_value = "1G", value_parser = parse_byte_size)] - pub download_size: u64, - /// Number of bytes to transmit from client to server - /// - /// This can use SI prefixes for sizes. E.g. 1M will transfer 1MiB, 10G - /// will transfer 10GiB. - #[clap(long, default_value = "0", value_parser = parse_byte_size)] - pub upload_size: u64, - /// Show connection stats the at the end of the benchmark - #[clap(long = "stats")] - pub stats: bool, - /// Whether to use the unordered read API - #[clap(long = "unordered")] - pub read_unordered: bool, - /// Starting guess for maximum UDP payload size - #[clap(long, default_value = "1200")] - pub initial_mtu: u16, - - /// Send buffer size in bytes - #[clap(long, default_value = "2097152")] - send_buffer_size: usize, - /// Receive buffer size in bytes - #[clap(long, default_value = "2097152")] - recv_buffer_size: usize, -} - /// Creates a server endpoint which runs on the given runtime pub fn server_endpoint(rt: &tokio::runtime::Runtime, opt: &Opt) -> (SocketAddr, quinn::Endpoint) { - let (key, cert) = { - let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]).unwrap(); - ( - rustls::PrivateKey(cert.serialize_private_key_der()), - vec![rustls::Certificate(cert.serialize_der().unwrap())], - ) - }; + let secret_key = iroh_net::key::SecretKey::generate(); + let crypto = + iroh_net::tls::make_server_config(&secret_key, vec![ALPN.to_vec()], false).unwrap(); - let mut crypto = rustls::ServerConfig::builder() - .with_cipher_suites(PERF_CIPHER_SUITES) - .with_safe_default_kx_groups() - .with_protocol_versions(&[&rustls::version::TLS13]) - .unwrap() - .with_no_client_auth() - .with_single_cert(cert, key) - .unwrap(); - crypto.alpn_protocols = vec![ALPN.to_vec()]; - - let transport = transport_config(opt); + let transport = transport_config(opt.max_streams, opt.initial_mtu); let mut server_config = quinn::ServerConfig::with_crypto(Arc::new(crypto)); server_config.transport_config(Arc::new(transport)); let addr = SocketAddr::new("127.0.0.1".parse().unwrap(), 0); - let socket = bind_socket(addr, opt.send_buffer_size, opt.recv_buffer_size).unwrap(); + let socket = bind_socket(addr).unwrap(); let _guard = rt.enter(); rt.block_on(async move { @@ -88,214 +33,81 @@ pub fn server_endpoint(rt: &tokio::runtime::Runtime, opt: &Opt) -> (SocketAddr, Some(server_config), socket, Arc::new(TokioRuntime), - ).unwrap(); + ) + .unwrap(); let addr = ep.local_addr().unwrap(); (addr, ep) }) } -pub fn transport_config(opt: &Opt) -> quinn::TransportConfig { - // High stream windows are chosen because the amount of concurrent streams - // is configurable as a parameter. - let mut config = quinn::TransportConfig::default(); - config.max_concurrent_uni_streams(opt.max_streams.try_into().unwrap()); - config.initial_mtu(opt.initial_mtu); - config -} - -pub static PERF_CIPHER_SUITES: &[rustls::SupportedCipherSuite] = &[ - rustls::cipher_suite::TLS13_AES_128_GCM_SHA256, - rustls::cipher_suite::TLS13_AES_256_GCM_SHA384, - rustls::cipher_suite::TLS13_CHACHA20_POLY1305_SHA256, -]; - -pub async fn server(endpoint: quinn::Endpoint, opt: Opt) -> Result<()> { - let mut server_tasks = Vec::new(); - - // Handle only the expected amount of clients - for _ in 0..opt.clients { - let handshake = endpoint.accept().await.unwrap(); - let connection = handshake.await.context("handshake failed")?; - - server_tasks.push(tokio::spawn(async move { - loop { - let (mut send_stream, mut recv_stream) = match connection.accept_bi().await { - Err(quinn::ConnectionError::ApplicationClosed(_)) => break, - Err(e) => { - eprintln!("accepting stream failed: {e:?}"); - break; - } - Ok(stream) => stream, - }; - trace!("stream established"); - - tokio::spawn(async move { - drain_stream(&mut recv_stream, opt.read_unordered).await?; - send_data_on_stream(&mut send_stream, opt.download_size).await?; - Ok::<_, anyhow::Error>(()) - }); - } - - if opt.stats { - println!("\nServer connection stats:\n{:#?}", connection.stats()); - } - })); - } - - // Await all the tasks. We have to do this to prevent the runtime getting dropped - // and all server tasks to be cancelled - for handle in server_tasks { - if let Err(e) = handle.await { - eprintln!("Server task error: {e:?}"); - }; - } - - Ok(()) -} - - +/// Create and run a client pub async fn client(server_addr: SocketAddr, opt: Opt) -> Result { let (endpoint, connection) = connect_client(server_addr, opt).await?; - - let start = Instant::now(); - - let connection = Arc::new(connection); - - let mut stats = ClientStats::default(); - let mut first_error = None; - - let sem = Arc::new(Semaphore::new(opt.max_streams)); - let results = Arc::new(Mutex::new(Vec::new())); - for _ in 0..opt.streams { - let permit = sem.clone().acquire_owned().await.unwrap(); - let results = results.clone(); - let connection = connection.clone(); - tokio::spawn(async move { - let result = - handle_client_stream(connection, opt.upload_size, opt.read_unordered).await; - info!("stream finished: {:?}", result); - results.lock().unwrap().push(result); - drop(permit); - }); - } - - // Wait for remaining streams to finish - let _ = sem.acquire_many(opt.max_streams as u32).await.unwrap(); - - for result in results.lock().unwrap().drain(..) { - match result { - Ok((upload_result, download_result)) => { - stats.upload_stats.stream_finished(upload_result); - stats.download_stats.stream_finished(download_result); - } - Err(e) => { - if first_error.is_none() { - first_error = Some(e); - } - } - } - } - - stats.upload_stats.total_duration = start.elapsed(); - stats.download_stats.total_duration = start.elapsed(); - - // Explicit close of the connection, since handles can still be around due - // to `Arc`ing them - connection.close(0u32.into(), b"Benchmark done"); - - endpoint.close(0u32.into(), b""); - - if opt.stats { - println!("\nClient connection stats:\n{:#?}", connection.stats()); - } - - match first_error { - None => Ok(stats), - Some(e) => Err(e), - } + client_handler(Endpoint::Quinn(endpoint), connection, opt).await } /// Create a client endpoint and client connection pub async fn connect_client( - // rt: &tokio::runtime::Runtime, server_addr: SocketAddr, opt: Opt, -) -> Result<(Endpoint, Connection)> { - // let endpoint = MagicEndpoint::builder() - // .alpns(vec![ALPN.to_vec()]) - // .relay_mode(RelayMode::Disabled) - // .transport_config(transport_config(&opt)) - // .bind(0) - // .await - // .unwrap(); - - // // TODO: We don't support passing client transport config currently - // // let mut client_config = quinn::ClientConfig::new(Arc::new(crypto)); - // // client_config.transport_config(Arc::new(transport_config(&opt))); - - // let connection = endpoint - // .connect(server_addr, ALPN) - // .await - // .context("unable to connect")?; - // trace!("connected"); - +) -> Result<(::quinn::Endpoint, Connection)> { + let secret_key = iroh_net::key::SecretKey::generate(); + let tls_client_config = + iroh_net::tls::make_client_config(&secret_key, None, vec![ALPN.to_vec()], false)?; + let mut config = quinn::ClientConfig::new(Arc::new(tls_client_config)); - let mut crypto = rustls::ClientConfig::builder() - .with_cipher_suites(PERF_CIPHER_SUITES) - .with_safe_default_kx_groups() - .with_protocol_versions(&[&rustls::version::TLS13]) - .unwrap() - .with_custom_certificate_verifier(SkipServerVerification::new()) - .with_no_client_auth(); - crypto.alpn_protocols = vec![ALPN.to_vec()]; + let transport = transport_config(opt.max_streams, opt.initial_mtu); - let transport = transport_config(&opt); - - let mut config = quinn::ClientConfig::new(Arc::new(crypto)); + // let mut config = quinn::ClientConfig::new(Arc::new(crypto)); config.transport_config(Arc::new(transport)); let addr = SocketAddr::new("127.0.0.1".parse().unwrap(), 0); - let socket = bind_socket(addr, opt.send_buffer_size, opt.recv_buffer_size).unwrap(); + let socket = bind_socket(addr).unwrap(); - // let _guard = rt.enter(); - // rt.block_on(async move { - let ep = quinn::Endpoint::new( - Default::default(), - None, - socket, - Arc::new(TokioRuntime), - ).unwrap(); - // let addr = ep.local_addr().unwrap(); - // (addr, ep) - let connection = ep + let ep = + quinn::Endpoint::new(Default::default(), None, socket, Arc::new(TokioRuntime)).unwrap(); + let connection = ep .connect_with(config, server_addr, "local")? .await - .context("connecting").unwrap(); - Ok((ep, connection)) - // }) - - // Ok((endpoint, connection)) + .context("connecting") + .unwrap(); + Ok((ep, connection)) } -struct SkipServerVerification; +fn bind_socket(addr: SocketAddr) -> Result { + let socket = Socket::new(Domain::for_address(addr), Type::DGRAM, Some(Protocol::UDP)) + .context("create socket")?; -impl SkipServerVerification { - fn new() -> Arc { - Arc::new(Self) + if addr.is_ipv6() { + socket.set_only_v6(false).context("set_only_v6")?; + } + + socket + .bind(&socket2::SockAddr::from(addr)) + .context("binding endpoint")?; + socket + .set_send_buffer_size(SOCKET_BUFFER_SIZE) + .context("send buffer size")?; + socket + .set_recv_buffer_size(SOCKET_BUFFER_SIZE) + .context("recv buffer size")?; + + let buf_size = socket.send_buffer_size().context("send buffer size")?; + if buf_size < SOCKET_BUFFER_SIZE { + warn!( + "Unable to set desired send buffer size. Desired: {}, Actual: {}", + SOCKET_BUFFER_SIZE, buf_size + ); } -} -impl rustls::client::ServerCertVerifier for SkipServerVerification { - fn verify_server_cert( - &self, - _end_entity: &rustls::Certificate, - _intermediates: &[rustls::Certificate], - _server_name: &rustls::ServerName, - _scts: &mut dyn Iterator, - _ocsp_response: &[u8], - _now: std::time::SystemTime, - ) -> Result { - Ok(rustls::client::ServerCertVerified::assertion()) + let buf_size = socket.recv_buffer_size().context("recv buffer size")?; + if buf_size < SOCKET_BUFFER_SIZE { + warn!( + "Unable to set desired recv buffer size. Desired: {}, Actual: {}", + SOCKET_BUFFER_SIZE, buf_size + ); } -} \ No newline at end of file + + Ok(socket.into()) +} diff --git a/iroh-net/bench/src/s2n.rs b/iroh-net/bench/src/s2n.rs index b30cfd83fa..cd5ddb5ed5 100644 --- a/iroh-net/bench/src/s2n.rs +++ b/iroh-net/bench/src/s2n.rs @@ -2,5 +2,4 @@ use clap::Parser; #[derive(Parser, Debug, Clone, Copy)] #[clap(name = "s2n")] -pub struct Opt { -} \ No newline at end of file +pub struct Opt {}