From a15764a13361f7fb222feb900f577247c6557965 Mon Sep 17 00:00:00 2001 From: Caio Date: Sun, 26 Jul 2026 19:23:01 -0300 Subject: [PATCH 1/2] [WTX] Update gRPC --- frameworks/wtx-grpc/Cargo.lock | 263 +++++++++++++++++++++++++++++--- frameworks/wtx-grpc/Cargo.toml | 4 +- frameworks/wtx-grpc/Dockerfile | 2 +- frameworks/wtx-grpc/src/main.rs | 58 ++----- 4 files changed, 265 insertions(+), 62 deletions(-) diff --git a/frameworks/wtx-grpc/Cargo.lock b/frameworks/wtx-grpc/Cargo.lock index 14a9202b2..0f904fb1b 100644 --- a/frameworks/wtx-grpc/Cargo.lock +++ b/frameworks/wtx-grpc/Cargo.lock @@ -2,6 +2,12 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "bitflags" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" + [[package]] name = "byteorder" version = "1.5.0" @@ -10,9 +16,41 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.11.1" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "cc" +version = "1.2.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" +checksum = "f5d6cac793997bd970000024b2934968efe83b382de4fdcf4fcb46b6ee4ad996" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" [[package]] name = "foldhash" @@ -20,6 +58,17 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "hashbrown" version = "0.17.1" @@ -39,23 +88,38 @@ dependencies = [ "wtx", ] +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + [[package]] name = "libc" version = "0.2.186" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + [[package]] name = "log" -version = "0.4.32" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953f07c43838f8e6f9758cab68bf5bed85465e7587ebe0b823f1bcd81978ad3a" +checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" [[package]] name = "memchr" -version = "2.8.1" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b947ae49db0d222b1dbc6b113ce7248a3fc3a6ca21b696717bfc000ba4484d8" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "minimal-lexical" @@ -71,7 +135,7 @@ checksum = "02bd0af71c67b473010cbbc60715ee815645a4dc942899111f494b4b737d6fda" dependencies = [ "libc", "wasi", - "windows-sys", + "windows-sys 0.61.2", ] [[package]] @@ -84,6 +148,29 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + [[package]] name = "pb-rs" version = "0.10.0" @@ -120,19 +207,70 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.45" +version = "1.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368" dependencies = [ "proc-macro2", ] +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + [[package]] name = "simdutf8" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" +[[package]] +name = "smallvec" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" + [[package]] name = "socket2" version = "0.6.4" @@ -140,14 +278,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52d1cfed4120b4d927bf7c0f86d2087a4a7d6027c906d9f9d525a80573b9be51" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.61.2", ] [[package]] name = "syn" -version = "2.0.117" +version = "2.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" dependencies = [ "proc-macro2", "quote", @@ -163,10 +301,12 @@ dependencies = [ "bytes", "libc", "mio", + "parking_lot", "pin-project-lite", + "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys", + "windows-sys 0.61.2", ] [[package]] @@ -186,6 +326,12 @@ version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "wasi" version = "0.11.1+wasi-snapshot-preview1" @@ -198,6 +344,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.61.2" @@ -207,29 +362,103 @@ dependencies = [ "windows-link", ] +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "wtx" -version = "0.47.7" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c279248c9635d9b0fdc17ee6674c1de0e3004a6853eec9f428ef0b4c2d2080e" +checksum = "9a348485f9b75dcf89dd3809a02dc6a52ec70fe7ab3ee66cb77b52d1bba8ecd8" dependencies = [ "foldhash", "hashbrown", + "httparse", "memchr", + "pin-project-lite", "quick-protobuf", + "ring", "simdutf8", "socket2", "tokio", "wtx-macros", + "zlib-rs", ] [[package]] name = "wtx-macros" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5c1e7897187f23097a7d1aadf7a76b834051471e8ce6d226513943c137c3acb" +checksum = "be1a392d00e36d5dd936ef583094d50e015981d159e0e12cd7b8cd665cea29d2" dependencies = [ "proc-macro2", "quote", "syn", ] + +[[package]] +name = "zlib-rs" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b142a20ec14a91d5bc708c1dc21b080c550113d8aa77afa29635673a65dd02c5" diff --git a/frameworks/wtx-grpc/Cargo.toml b/frameworks/wtx-grpc/Cargo.toml index 2c3f50b41..b989cd386 100644 --- a/frameworks/wtx-grpc/Cargo.toml +++ b/frameworks/wtx-grpc/Cargo.toml @@ -8,8 +8,8 @@ pb-rs = { default-features = false, version = "0.10" } [dependencies] quick-protobuf = { default-features = false, version = "0.8" } -tokio = { default-features = false, features = ["macros", "rt-multi-thread"], version = "1.0" } -wtx = { default-features = false, features = ["grpc-server", "http-server-framework", "optimizations", "optioned-server", "quick-protobuf", "tokio"], version = "0.47" } +tokio = { default-features = false, features = ["full"], version = "1.0" } +wtx = { default-features = false, features = ["grpc-server", "optimizations-std", "quick-protobuf", "tokio"], version = "0.49" } [profile.release] codegen-units = 1 diff --git a/frameworks/wtx-grpc/Dockerfile b/frameworks/wtx-grpc/Dockerfile index 14dde7620..181379cfd 100644 --- a/frameworks/wtx-grpc/Dockerfile +++ b/frameworks/wtx-grpc/Dockerfile @@ -1,5 +1,5 @@ FROM rust:1.95 AS build -RUN rustup default nightly-2026-05-07 +RUN rustup default nightly-2026-06-27 WORKDIR /app COPY Cargo.toml build.rs ./ COPY proto ./proto diff --git a/frameworks/wtx-grpc/src/main.rs b/frameworks/wtx-grpc/src/main.rs index bba8073f0..a634f104c 100644 --- a/frameworks/wtx-grpc/src/main.rs +++ b/frameworks/wtx-grpc/src/main.rs @@ -1,57 +1,31 @@ pub mod grpc_bindings; +use grpc_bindings::benchmark::{SumReply, SumRequest}; use wtx::{ codec::format::QuickProtobuf, - collection::Vector, grpc::{GrpcManager, GrpcMiddleware}, http::{ - HttpRecvParams, MsgBufferString, - server_framework::{Router, ServerFrameworkBuilder, State, post}, + HttpRecvParams, + http2_server_framework::{Http2ServerFramework, HttpRouter, State, post}, }, + tls::TlsConfig, }; -fn main() { - let threads = std::thread::available_parallelism().map(|el| el.get()).unwrap_or(1); - let mut handlers = Vector::new(); - for _ in 0..threads { - let handle = std::thread::spawn(|| { - tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(serve()) - }); - handlers.push(handle).unwrap(); - } - for handle in handlers { - handle.join().unwrap(); - } +fn main() -> wtx::Result<()> { + let router = HttpRouter::new( + wtx::paths!(("/benchmark.BenchmarkService/GetSum", post(endpoint_grpc_unary))), + GrpcMiddleware, + )?; + Http2ServerFramework::tokio(TlsConfig::plaintext())? + .set_data(GrpcManager::from_drsr(QuickProtobuf)) + .set_http_recv_params(HttpRecvParams::with_permissive_params()) + .run_in_threads("0.0.0.0:8080", router) } -async fn endpoint_grpc_unary( - state: State<'_, (), GrpcManager, MsgBufferString>, -) -> wtx::Result<()> { - let sr: grpc_bindings::benchmark::SumRequest = - state.stream_aux.des_from_req_bytes(&mut state.req.msg_data.body.as_slice())?; +async fn endpoint_grpc_unary(state: State<'_, GrpcManager>) -> wtx::Result<()> { + let sr = state.data.des_from_req_bytes::(&mut state.req.msg_data.body.as_slice())?; state.req.clear(); let result = sr.a.wrapping_add(sr.b); - state.stream_aux.ser_to_res_bytes( - &mut state.req.msg_data.body, - grpc_bindings::benchmark::SumReply { result }, - )?; + state.data.ser_to_res_bytes(&mut state.req.msg_data.body, SumReply { result })?; Ok(()) } - -async fn serve() { - let router = Router::new( - wtx::paths!(("/benchmark.BenchmarkService/GetSum", post(endpoint_grpc_unary))), - GrpcMiddleware, - ) - .unwrap(); - let _rslt = ServerFrameworkBuilder::new(HttpRecvParams::with_permissive_params(), router) - .with_stream_aux(|_| Ok(QuickProtobuf)) - .tokio( - "0.0.0.0:8080", - |_error| {}, - |_| Ok(()), - |_stream| Ok(()), - |_error| {}, - ) - .await; -} From cf0447f8aefeb2e262e842d949c4756151ec08ba Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 27 Jul 2026 13:28:23 +0000 Subject: [PATCH 2/2] Benchmark results: wtx-grpc --- site/data/results/wtx.json | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/site/data/results/wtx.json b/site/data/results/wtx.json index 8ac6a2cc5..906701e9a 100644 --- a/site/data/results/wtx.json +++ b/site/data/results/wtx.json @@ -251,18 +251,18 @@ "unary-grpc-1024": { "framework": "wtx", "language": "Rust", - "rps": 2309935, - "avg_latency": "42.34ms", - "p99_latency": "42.34ms", - "cpu": "6489.9%", - "memory": "793MiB", + "rps": 2400296, + "avg_latency": "39.98ms", + "p99_latency": "1.04s", + "cpu": "6438.2%", + "memory": "896MiB", "connections": 1024, "threads": 64, "duration": "5s", "pipeline": 1, - "bandwidth": "100.53MB/s", + "bandwidth": "104.46MB/s", "reconnects": 0, - "status_2xx": 11711374, + "status_2xx": 12169501, "status_3xx": 0, "status_4xx": 0, "status_5xx": 0 @@ -270,18 +270,18 @@ "unary-grpc-256": { "framework": "wtx", "language": "Rust", - "rps": 2381186, - "avg_latency": "11.16ms", - "p99_latency": "11.16ms", - "cpu": "6486.5%", - "memory": "473MiB", + "rps": 2478340, + "avg_latency": "11.14ms", + "p99_latency": "259.06ms", + "cpu": "6469.9%", + "memory": "523MiB", "connections": 256, "threads": 64, "duration": "5s", "pipeline": 1, - "bandwidth": "103.01MB/s", + "bandwidth": "107.00MB/s", "reconnects": 0, - "status_2xx": 12001180, + "status_2xx": 12466055, "status_3xx": 0, "status_4xx": 0, "status_5xx": 0