Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions frameworks/Rust/ntex/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ntex-bench"
version = "2.0.0"
version = "2.1.0"
edition = "2018"

[[bin]]
Expand All @@ -11,6 +11,10 @@ path = "src/main.rs"
name = "ntex-compio"
path = "src/main.rs"

[[bin]]
name = "ntex-neon"
path = "src/main.rs"

[[bin]]
name = "ntex-db"
path = "src/main_db.rs"
Expand All @@ -19,6 +23,10 @@ path = "src/main_db.rs"
name = "ntex-db-compio"
path = "src/main_db.rs"

[[bin]]
name = "ntex-db-neon"
path = "src/main_db.rs"

[[bin]]
name = "ntex-plt"
path = "src/main_plt.rs"
Expand All @@ -27,6 +35,10 @@ path = "src/main_plt.rs"
name = "ntex-plt-compio"
path = "src/main_plt.rs"

[[bin]]
name = "ntex-plt-neon"
path = "src/main_plt.rs"

[features]
default = []

Expand All @@ -36,8 +48,11 @@ tokio = ["ntex/tokio"]
# compio runtime
compio = ["ntex/compio"]

# neon runtime
neon = ["ntex/neon"]

[dependencies]
ntex = "2.8"
ntex = "2.12"
ntex-compio = "0.2"
ntex-bytes = { version = "0.1.21", features=["simd"] }
mimalloc = { version = "0.1.25", default-features = false }
Expand All @@ -47,7 +62,6 @@ buf-min = { version = "0.7", features = ["ntex-bytes"] }
env_logger = "0.11"
nanorand = { version = "0.7", default-features = false, features = ["std", "wyrand", "tls"] }
atoi = "2.0"
core_affinity = "0.8"
futures = "0.3"
sonic-rs = "0.3.16"
serde = { version = "1", features = ["derive"] }
Expand All @@ -59,6 +73,13 @@ tokio-postgres = { git="https://github.com/fafhrd91/postgres.git", branch="ntex-
[target.'cfg(target_os = "linux")'.dependencies]
compio-driver = { version = "*", features = ["io-uring"]}

[patch.crates-io]
ntex = { git = "https://github.com/ntex-rs/ntex.git" }
ntex-io = { git = "https://github.com/ntex-rs/ntex.git" }
ntex-net = { git = "https://github.com/ntex-rs/ntex.git" }
ntex-rt = { git = "https://github.com/ntex-rs/ntex.git" }
ntex-neon = { git = "https://github.com/ntex-rs/ntex.git" }

[profile.release]
opt-level = 3
codegen-units = 1
Expand Down
56 changes: 56 additions & 0 deletions frameworks/Rust/ntex/benchmark_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@
"notes": "",
"versus": ""
},
"neon": {
"json_url": "/json",
"plaintext_url": "/plaintext",
"port": 8080,
"approach": "Realistic",
"classification": "Micro",
"database": "Postgres",
"framework": "ntex",
"language": "Rust",
"orm": "Raw",
"platform": "None",
"webserver": "ntex",
"os": "Linux",
"database_os": "Linux",
"display_name": "ntex [neon]",
"notes": "",
"versus": ""
},
"db": {
"fortune_url": "/fortunes",
"db_url": "/db",
Expand Down Expand Up @@ -77,6 +95,26 @@
"notes": "",
"versus": ""
},
"db-neon": {
"fortune_url": "/fortunes",
"db_url": "/db",
"query_url": "/query?q=",
"update_url": "/update?q=",
"port": 8080,
"approach": "Realistic",
"classification": "Micro",
"database": "Postgres",
"framework": "ntex",
"language": "Rust",
"orm": "Raw",
"platform": "None",
"webserver": "ntex",
"os": "Linux",
"database_os": "Linux",
"display_name": "ntex [neon,db]",
"notes": "",
"versus": ""
},
"plt": {
"json_url": "/json",
"plaintext_url": "/plaintext",
Expand Down Expand Up @@ -112,6 +150,24 @@
"display_name": "ntex [compio,platform]",
"notes": "",
"versus": ""
},
"plt-neon": {
"json_url": "/json",
"plaintext_url": "/plaintext",
"port": 8080,
"approach": "Realistic",
"classification": "Platform",
"database": "Postgres",
"framework": "ntex",
"language": "Rust",
"orm": "Raw",
"platform": "None",
"webserver": "ntex",
"os": "Linux",
"database_os": "Linux",
"display_name": "ntex [neon,platform]",
"notes": "",
"versus": ""
}
}]
}
41 changes: 41 additions & 0 deletions frameworks/Rust/ntex/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ platform = "None"
webserver = "ntex"
versus = ""

[neon]
urls.plaintext = "/plaintext"
urls.json = "/json"
approach = "Realistic"
classification = "Micro"
database = "Postgres"
database_os = "Linux"
os = "Linux"
orm = "Raw"
platform = "None"
webserver = "ntex"
versus = ""

[db]
urls.db = "/db"
urls.query = "/query?q="
Expand Down Expand Up @@ -57,6 +70,21 @@ platform = "None"
webserver = "ntex"
versus = ""

[db-neon]
urls.db = "/db"
urls.query = "/query?q="
urls.update = "/update?q="
urls.fortune = "/fortunes"
approach = "Realistic"
classification = "Micro"
database = "Postgres"
database_os = "Linux"
os = "Linux"
orm = "Raw"
platform = "None"
webserver = "ntex"
versus = ""

[plt]
urls.plaintext = "/plaintext"
urls.json = "/json"
Expand All @@ -82,3 +110,16 @@ orm = "Raw"
platform = "None"
webserver = "ntex"
versus = ""

[plt-neon]
urls.plaintext = "/plaintext"
urls.json = "/json"
approach = "Realistic"
classification = "Platform"
database = "Postgres"
database_os = "Linux"
os = "Linux"
orm = "Raw"
platform = "None"
webserver = "ntex"
versus = ""
16 changes: 16 additions & 0 deletions frameworks/Rust/ntex/ntex-db-neon.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM rust:latest

# Disable simd at jsonescape
# ENV CARGO_CFG_JSONESCAPE_DISABLE_AUTO_SIMD=

RUN apt-get update -yqq && apt-get install -yqq cmake g++

ADD ./ /ntex
WORKDIR /ntex

RUN cargo clean
RUN RUSTFLAGS="-C target-cpu=native" cargo build --release --features="neon"

EXPOSE 8080

CMD ./target/release/ntex-db-neon
16 changes: 16 additions & 0 deletions frameworks/Rust/ntex/ntex-neon.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM rust:latest

# Disable simd at jsonescape
# ENV CARGO_CFG_JSONESCAPE_DISABLE_AUTO_SIMD=

RUN apt-get update -yqq && apt-get install -yqq cmake g++

ADD ./ /ntex
WORKDIR /ntex

RUN cargo clean
RUN RUSTFLAGS="-C target-cpu=native" cargo build --release --features="neon"

EXPOSE 8080

CMD ./target/release/ntex-neon
16 changes: 16 additions & 0 deletions frameworks/Rust/ntex/ntex-plt-neon.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM rust:latest

# Disable simd at jsonescape
# ENV CARGO_CFG_JSONESCAPE_DISABLE_AUTO_SIMD=

RUN apt-get update -yqq && apt-get install -yqq cmake g++

ADD ./ /ntex
WORKDIR /ntex

RUN cargo clean
RUN RUSTFLAGS="-C target-cpu=native" cargo build --release --features="neon"

EXPOSE 8080

CMD ./target/release/ntex-plt-neon
2 changes: 1 addition & 1 deletion frameworks/Rust/ntex/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl PgConnection {
utils::reserve(&mut body, 4 * 1024);

FortunesTemplate {
fortunes: &*fortunes,
fortunes: &fortunes,
}
.write_call(&mut body);
fortunes.clear();
Expand Down
18 changes: 2 additions & 16 deletions frameworks/Rust/ntex/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

use ntex::http::header::{CONTENT_TYPE, SERVER};
use ntex::{http, time::Seconds, util::BytesMut, util::PoolId, util::Ready, web};
use ntex::{http, time::Seconds, util::BytesMut, util::PoolId, web};
use sonic_rs::Serialize;

mod utils;
Expand Down Expand Up @@ -48,13 +48,10 @@ async fn plaintext() -> web::HttpResponse {
async fn main() -> std::io::Result<()> {
println!("Started http server: 127.0.0.1:8080");

let cores = core_affinity::get_core_ids().unwrap();
let total_cores = cores.len();
let cores = std::sync::Arc::new(std::sync::Mutex::new(cores));

// start http server
ntex::server::build()
.backlog(1024)
.enable_affinity()
.bind("techempower", "0.0.0.0:8080", |cfg| {
cfg.memory_pool(PoolId::P1);
PoolId::P1.set_read_params(65535, 2048);
Expand All @@ -67,17 +64,6 @@ async fn main() -> std::io::Result<()> {
.payload_read_rate(Seconds::ZERO, Seconds::ZERO, 0)
.h1(web::App::new().service(json).service(plaintext).finish())
})?
.configure(move |cfg| {
let cores = cores.clone();
cfg.on_worker_start(move |_| {
if let Some(core) = cores.lock().unwrap().pop() {
core_affinity::set_for_current(core);
}
Ready::<_, &str>::Ok(())
});
Ok(())
})?
.workers(total_cores)
.run()
.await
}
18 changes: 2 additions & 16 deletions frameworks/Rust/ntex/src/main_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use ntex::http::header::{CONTENT_TYPE, SERVER};
use ntex::http::{HttpService, KeepAlive, Request, Response, StatusCode};
use ntex::service::{Service, ServiceCtx, ServiceFactory};
use ntex::web::{Error, HttpResponse};
use ntex::{time::Seconds, util::PoolId, util::Ready};
use ntex::{time::Seconds, util::PoolId};

mod db;
mod utils;
Expand Down Expand Up @@ -82,12 +82,9 @@ impl ServiceFactory<Request> for AppFactory {
async fn main() -> std::io::Result<()> {
println!("Starting http server: 127.0.0.1:8080");

let cores = core_affinity::get_core_ids().unwrap();
let total_cores = cores.len();
let cores = std::sync::Arc::new(std::sync::Mutex::new(cores));

ntex::server::build()
.backlog(1024)
.enable_affinity()
.bind("techempower", "0.0.0.0:8080", |cfg| {
cfg.memory_pool(PoolId::P1);
PoolId::P1.set_read_params(65535, 2048);
Expand All @@ -100,17 +97,6 @@ async fn main() -> std::io::Result<()> {
.payload_read_rate(Seconds::ZERO, Seconds::ZERO, 0)
.h1(AppFactory)
})?
.configure(move |cfg| {
let cores = cores.clone();
cfg.on_worker_start(move |_| {
if let Some(core) = cores.lock().unwrap().pop() {
core_affinity::set_for_current(core);
}
Ready::<_, &str>::Ok(())
});
Ok(())
})?
.workers(total_cores)
.run()
.await
}
Loading
Loading