From 75e54e7ff71c91ac725024e14e10e34527da1649 Mon Sep 17 00:00:00 2001 From: Pooya Eimandar Date: Fri, 27 Feb 2026 18:44:23 +0400 Subject: [PATCH 1/2] [Rust/sib] Bump to v0.0.17 --- frameworks/Rust/sib/Cargo.toml | 20 ++++++++++++++------ frameworks/Rust/sib/src/main.rs | 18 ++++++++++-------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/frameworks/Rust/sib/Cargo.toml b/frameworks/Rust/sib/Cargo.toml index 1358100f450..969691dd399 100644 --- a/frameworks/Rust/sib/Cargo.toml +++ b/frameworks/Rust/sib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sib-techempower" -version = "0.0.1" +version = "0.0.2" authors = ["mail@pooya.ai"] description = "A high-performance, secure, and cross-platform modules optimized for efficiency, scalability, and reliability." documentation = "https://docs.rs/sib" @@ -12,18 +12,26 @@ categories = ["development-tools"] readme = "README.md" [dependencies] -sib = { version = "0.0.15", default-features = false, features = [ +sib = { version = "0.0.17", default-features = false, features = [ "net-h1-server", ] } -bytes = { version = "1.10.1", default-features = false } +bytes = { version = "1.11.1", default-features = false } heapless = { version = "0.9.1", default-features = false } -http = { version = "1.3.1", default-features = false } mimalloc = { version = "0.1.48", default-features = false, features = [ "secure", ] } num_cpus = { version = "1.17.0", default-features = false } -serde = { version = "1.0.221", default-features = false, features = ["derive"] } -serde_json = { version = "1.0.144", default-features = false, features = [ +serde = { version = "1.0.228", default-features = false, features = ["derive"] } +serde_json = { version = "1.0.149", default-features = false, features = [ + "std", +] } +tracing = { version = "0.1.44", default-features = false, features = [ + "attributes", + "std", +] } +tracing-subscriber = { version = "0.3.22", features = [ + "fmt", + "env-filter", "std", ] } diff --git a/frameworks/Rust/sib/src/main.rs b/frameworks/Rust/sib/src/main.rs index 0013400cf8a..7352fbadc19 100644 --- a/frameworks/Rust/sib/src/main.rs +++ b/frameworks/Rust/sib/src/main.rs @@ -1,3 +1,5 @@ +// TechEmpower benchmark tests for Sib with the `net-h1-server` feature enabled + use sib::network::http::{ server::{H1Config, HFactory}, session::{HService, Session}, @@ -24,10 +26,10 @@ struct Server; impl HService for Server { fn call(&mut self, session: &mut S) -> std::io::Result<()> { use core::fmt::Write; - use sib::network::http::h1_session; - if session.req_path() == "/json" { + let time = sib::network::http::date::current_date_str(); + let mut res: heapless::String<256> = heapless::String::new(); + if session.req_path_bytes() == b"/json" { // Respond with JSON - let mut res: heapless::String<192> = heapless::String::new(); let json = serde_json::to_vec(&JsonMessage::default())?; write!( res, @@ -38,14 +40,13 @@ impl HService for Server { Content-Length: {}\r\n\ \r\n\ {}", - h1_session::CURRENT_DATE.load(), + time, &json.len().to_string(), String::from_utf8_lossy(&json) ) .unwrap(); session.write_all_eom(res.as_bytes()) } else { - let mut res: heapless::String<160> = heapless::String::new(); write!( res, "HTTP/1.1 200 OK\r\n\ @@ -55,7 +56,7 @@ impl HService for Server { Content-Length: 13\r\n\ \r\n\ Hello, World!", - h1_session::CURRENT_DATE.load() + time ) .unwrap(); session.write_all_eom(res.as_bytes()) @@ -72,7 +73,7 @@ impl HFactory for Server { } fn main() { - let stack_size = 4 * 1024; // 4 KB stack + let stack_size = 2 * 1024; // 2 KB stack let cpus = num_cpus::get(); sib::init_global_poller(cpus, stack_size); @@ -84,13 +85,14 @@ fn main() { for _ in 0..cpus { let handle = std::thread::spawn(move || { let id = std::thread::current().id(); - println!("Listening {addr} on thread: {id:?}"); + tracing::info!("Listening {addr} on thread: {id:?}"); Server .start_h1( addr, H1Config { io_timeout: std::time::Duration::from_secs(15), stack_size, + ..Default::default() }, ) .unwrap_or_else(|_| panic!("H1 server failed to start for thread {id:?}")) From 503151e6095abff1be5f593d32e2d89134d65b8a Mon Sep 17 00:00:00 2001 From: Pooya Eimandar Date: Sun, 8 Mar 2026 13:39:33 +0400 Subject: [PATCH 2/2] pef: Realistic approach --- frameworks/Rust/sib/Cargo.toml | 4 +- frameworks/Rust/sib/benchmark_config.json | 4 +- frameworks/Rust/sib/src/main.rs | 58 +++++++++-------------- 3 files changed, 26 insertions(+), 40 deletions(-) diff --git a/frameworks/Rust/sib/Cargo.toml b/frameworks/Rust/sib/Cargo.toml index 969691dd399..14534469f0d 100644 --- a/frameworks/Rust/sib/Cargo.toml +++ b/frameworks/Rust/sib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sib-techempower" -version = "0.0.2" +version = "0.0.3" authors = ["mail@pooya.ai"] description = "A high-performance, secure, and cross-platform modules optimized for efficiency, scalability, and reliability." documentation = "https://docs.rs/sib" @@ -16,7 +16,7 @@ sib = { version = "0.0.17", default-features = false, features = [ "net-h1-server", ] } bytes = { version = "1.11.1", default-features = false } -heapless = { version = "0.9.1", default-features = false } +http = { version = "1.4.0", default-features = false, features = ["std"] } mimalloc = { version = "0.1.48", default-features = false, features = [ "secure", ] } diff --git a/frameworks/Rust/sib/benchmark_config.json b/frameworks/Rust/sib/benchmark_config.json index e26db6c5276..ab0bc82eb86 100644 --- a/frameworks/Rust/sib/benchmark_config.json +++ b/frameworks/Rust/sib/benchmark_config.json @@ -6,7 +6,7 @@ "json_url": "/json", "plaintext_url": "/plaintext", "port": 8080, - "approach": "Stripped", + "approach": "Realistic", "classification": "Fullstack", "framework": "sib", "language": "Rust", @@ -21,4 +21,4 @@ } } ] -} +} \ No newline at end of file diff --git a/frameworks/Rust/sib/src/main.rs b/frameworks/Rust/sib/src/main.rs index 7352fbadc19..fb86c1484a5 100644 --- a/frameworks/Rust/sib/src/main.rs +++ b/frameworks/Rust/sib/src/main.rs @@ -1,5 +1,6 @@ // TechEmpower benchmark tests for Sib with the `net-h1-server` feature enabled - +use bytes::Bytes; +use http::StatusCode; use sib::network::http::{ server::{H1Config, HFactory}, session::{HService, Session}, @@ -8,6 +9,8 @@ use sib::network::http::{ #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; +const PLAINTEXT_BODY: &[u8] = b"Hello, World!"; +const PLAINTEXT_CONTENT_LENGTH: &str = "13"; #[derive(serde::Serialize)] struct JsonMessage<'a> { message: &'a str, @@ -25,41 +28,24 @@ struct Server; impl HService for Server { fn call(&mut self, session: &mut S) -> std::io::Result<()> { - use core::fmt::Write; - let time = sib::network::http::date::current_date_str(); - let mut res: heapless::String<256> = heapless::String::new(); - if session.req_path_bytes() == b"/json" { - // Respond with JSON - let json = serde_json::to_vec(&JsonMessage::default())?; - write!( - res, - "HTTP/1.1 200 OK\r\n\ - Server: sib\r\n\ - Date: {}\r\n\ - Content-Type: application/json\r\n\ - Content-Length: {}\r\n\ - \r\n\ - {}", - time, - &json.len().to_string(), - String::from_utf8_lossy(&json) - ) - .unwrap(); - session.write_all_eom(res.as_bytes()) - } else { - write!( - res, - "HTTP/1.1 200 OK\r\n\ - Server: sib\r\n\ - Date: {}\r\n\ - Content-Type: text/plain\r\n\ - Content-Length: 13\r\n\ - \r\n\ - Hello, World!", - time - ) - .unwrap(); - session.write_all_eom(res.as_bytes()) + match session.req_path_bytes() { + b"/json" => { + let json = serde_json::to_vec(&JsonMessage::default())?; + let json_len = json.len().to_string(); + + session + .status_code(StatusCode::OK) + .header_str("Content-Type", "application/json")? + .header_str("Content-Length", json_len.as_str())? + .body(json.into()) + .eom() + } + _ => session + .status_code(StatusCode::OK) + .header_str("Content-Type", "text/plain")? + .header_str("Content-Length", PLAINTEXT_CONTENT_LENGTH)? + .body(Bytes::from_static(PLAINTEXT_BODY)) + .eom(), } } }