Skip to content

Commit 3c194d8

Browse files
Merge pull request #9627 from fafhrd91/ntex-fixes-11
[ntex] update version
2 parents ffc04a1 + 513db94 commit 3c194d8

File tree

11 files changed

+179
-56
lines changed

11 files changed

+179
-56
lines changed

frameworks/Rust/ntex/Cargo.toml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ntex-bench"
3-
version = "2.0.0"
3+
version = "2.1.0"
44
edition = "2018"
55

66
[[bin]]
@@ -11,6 +11,10 @@ path = "src/main.rs"
1111
name = "ntex-compio"
1212
path = "src/main.rs"
1313

14+
[[bin]]
15+
name = "ntex-neon"
16+
path = "src/main.rs"
17+
1418
[[bin]]
1519
name = "ntex-db"
1620
path = "src/main_db.rs"
@@ -19,6 +23,10 @@ path = "src/main_db.rs"
1923
name = "ntex-db-compio"
2024
path = "src/main_db.rs"
2125

26+
[[bin]]
27+
name = "ntex-db-neon"
28+
path = "src/main_db.rs"
29+
2230
[[bin]]
2331
name = "ntex-plt"
2432
path = "src/main_plt.rs"
@@ -27,6 +35,10 @@ path = "src/main_plt.rs"
2735
name = "ntex-plt-compio"
2836
path = "src/main_plt.rs"
2937

38+
[[bin]]
39+
name = "ntex-plt-neon"
40+
path = "src/main_plt.rs"
41+
3042
[features]
3143
default = []
3244

@@ -36,8 +48,11 @@ tokio = ["ntex/tokio"]
3648
# compio runtime
3749
compio = ["ntex/compio"]
3850

51+
# neon runtime
52+
neon = ["ntex/neon"]
53+
3954
[dependencies]
40-
ntex = "2.8"
55+
ntex = "2.12"
4156
ntex-compio = "0.2"
4257
ntex-bytes = { version = "0.1.21", features=["simd"] }
4358
mimalloc = { version = "0.1.25", default-features = false }
@@ -47,7 +62,6 @@ buf-min = { version = "0.7", features = ["ntex-bytes"] }
4762
env_logger = "0.11"
4863
nanorand = { version = "0.7", default-features = false, features = ["std", "wyrand", "tls"] }
4964
atoi = "2.0"
50-
core_affinity = "0.8"
5165
futures = "0.3"
5266
sonic-rs = "0.3.16"
5367
serde = { version = "1", features = ["derive"] }
@@ -59,6 +73,13 @@ tokio-postgres = { git="https://github.com/fafhrd91/postgres.git", branch="ntex-
5973
[target.'cfg(target_os = "linux")'.dependencies]
6074
compio-driver = { version = "*", features = ["io-uring"]}
6175

76+
[patch.crates-io]
77+
ntex = { git = "https://github.com/ntex-rs/ntex.git" }
78+
ntex-io = { git = "https://github.com/ntex-rs/ntex.git" }
79+
ntex-net = { git = "https://github.com/ntex-rs/ntex.git" }
80+
ntex-rt = { git = "https://github.com/ntex-rs/ntex.git" }
81+
ntex-neon = { git = "https://github.com/ntex-rs/ntex.git" }
82+
6283
[profile.release]
6384
opt-level = 3
6485
codegen-units = 1

frameworks/Rust/ntex/benchmark_config.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,24 @@
3737
"notes": "",
3838
"versus": ""
3939
},
40+
"neon": {
41+
"json_url": "/json",
42+
"plaintext_url": "/plaintext",
43+
"port": 8080,
44+
"approach": "Realistic",
45+
"classification": "Micro",
46+
"database": "Postgres",
47+
"framework": "ntex",
48+
"language": "Rust",
49+
"orm": "Raw",
50+
"platform": "None",
51+
"webserver": "ntex",
52+
"os": "Linux",
53+
"database_os": "Linux",
54+
"display_name": "ntex [neon]",
55+
"notes": "",
56+
"versus": ""
57+
},
4058
"db": {
4159
"fortune_url": "/fortunes",
4260
"db_url": "/db",
@@ -77,6 +95,26 @@
7795
"notes": "",
7896
"versus": ""
7997
},
98+
"db-neon": {
99+
"fortune_url": "/fortunes",
100+
"db_url": "/db",
101+
"query_url": "/query?q=",
102+
"update_url": "/update?q=",
103+
"port": 8080,
104+
"approach": "Realistic",
105+
"classification": "Micro",
106+
"database": "Postgres",
107+
"framework": "ntex",
108+
"language": "Rust",
109+
"orm": "Raw",
110+
"platform": "None",
111+
"webserver": "ntex",
112+
"os": "Linux",
113+
"database_os": "Linux",
114+
"display_name": "ntex [neon,db]",
115+
"notes": "",
116+
"versus": ""
117+
},
80118
"plt": {
81119
"json_url": "/json",
82120
"plaintext_url": "/plaintext",
@@ -112,6 +150,24 @@
112150
"display_name": "ntex [compio,platform]",
113151
"notes": "",
114152
"versus": ""
153+
},
154+
"plt-neon": {
155+
"json_url": "/json",
156+
"plaintext_url": "/plaintext",
157+
"port": 8080,
158+
"approach": "Realistic",
159+
"classification": "Platform",
160+
"database": "Postgres",
161+
"framework": "ntex",
162+
"language": "Rust",
163+
"orm": "Raw",
164+
"platform": "None",
165+
"webserver": "ntex",
166+
"os": "Linux",
167+
"database_os": "Linux",
168+
"display_name": "ntex [neon,platform]",
169+
"notes": "",
170+
"versus": ""
115171
}
116172
}]
117173
}

frameworks/Rust/ntex/config.toml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ platform = "None"
2727
webserver = "ntex"
2828
versus = ""
2929

30+
[neon]
31+
urls.plaintext = "/plaintext"
32+
urls.json = "/json"
33+
approach = "Realistic"
34+
classification = "Micro"
35+
database = "Postgres"
36+
database_os = "Linux"
37+
os = "Linux"
38+
orm = "Raw"
39+
platform = "None"
40+
webserver = "ntex"
41+
versus = ""
42+
3043
[db]
3144
urls.db = "/db"
3245
urls.query = "/query?q="
@@ -57,6 +70,21 @@ platform = "None"
5770
webserver = "ntex"
5871
versus = ""
5972

73+
[db-neon]
74+
urls.db = "/db"
75+
urls.query = "/query?q="
76+
urls.update = "/update?q="
77+
urls.fortune = "/fortunes"
78+
approach = "Realistic"
79+
classification = "Micro"
80+
database = "Postgres"
81+
database_os = "Linux"
82+
os = "Linux"
83+
orm = "Raw"
84+
platform = "None"
85+
webserver = "ntex"
86+
versus = ""
87+
6088
[plt]
6189
urls.plaintext = "/plaintext"
6290
urls.json = "/json"
@@ -82,3 +110,16 @@ orm = "Raw"
82110
platform = "None"
83111
webserver = "ntex"
84112
versus = ""
113+
114+
[plt-neon]
115+
urls.plaintext = "/plaintext"
116+
urls.json = "/json"
117+
approach = "Realistic"
118+
classification = "Platform"
119+
database = "Postgres"
120+
database_os = "Linux"
121+
os = "Linux"
122+
orm = "Raw"
123+
platform = "None"
124+
webserver = "ntex"
125+
versus = ""
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM rust:latest
2+
3+
# Disable simd at jsonescape
4+
# ENV CARGO_CFG_JSONESCAPE_DISABLE_AUTO_SIMD=
5+
6+
RUN apt-get update -yqq && apt-get install -yqq cmake g++
7+
8+
ADD ./ /ntex
9+
WORKDIR /ntex
10+
11+
RUN cargo clean
12+
RUN RUSTFLAGS="-C target-cpu=native" cargo build --release --features="neon"
13+
14+
EXPOSE 8080
15+
16+
CMD ./target/release/ntex-db-neon
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM rust:latest
2+
3+
# Disable simd at jsonescape
4+
# ENV CARGO_CFG_JSONESCAPE_DISABLE_AUTO_SIMD=
5+
6+
RUN apt-get update -yqq && apt-get install -yqq cmake g++
7+
8+
ADD ./ /ntex
9+
WORKDIR /ntex
10+
11+
RUN cargo clean
12+
RUN RUSTFLAGS="-C target-cpu=native" cargo build --release --features="neon"
13+
14+
EXPOSE 8080
15+
16+
CMD ./target/release/ntex-neon
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM rust:latest
2+
3+
# Disable simd at jsonescape
4+
# ENV CARGO_CFG_JSONESCAPE_DISABLE_AUTO_SIMD=
5+
6+
RUN apt-get update -yqq && apt-get install -yqq cmake g++
7+
8+
ADD ./ /ntex
9+
WORKDIR /ntex
10+
11+
RUN cargo clean
12+
RUN RUSTFLAGS="-C target-cpu=native" cargo build --release --features="neon"
13+
14+
EXPOSE 8080
15+
16+
CMD ./target/release/ntex-plt-neon

frameworks/Rust/ntex/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl PgConnection {
173173
utils::reserve(&mut body, 4 * 1024);
174174

175175
FortunesTemplate {
176-
fortunes: &*fortunes,
176+
fortunes: &fortunes,
177177
}
178178
.write_call(&mut body);
179179
fortunes.clear();

frameworks/Rust/ntex/src/main.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
33

44
use ntex::http::header::{CONTENT_TYPE, SERVER};
5-
use ntex::{http, time::Seconds, util::BytesMut, util::PoolId, util::Ready, web};
5+
use ntex::{http, time::Seconds, util::BytesMut, util::PoolId, web};
66
use sonic_rs::Serialize;
77

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

51-
let cores = core_affinity::get_core_ids().unwrap();
52-
let total_cores = cores.len();
53-
let cores = std::sync::Arc::new(std::sync::Mutex::new(cores));
54-
5551
// start http server
5652
ntex::server::build()
5753
.backlog(1024)
54+
.enable_affinity()
5855
.bind("techempower", "0.0.0.0:8080", |cfg| {
5956
cfg.memory_pool(PoolId::P1);
6057
PoolId::P1.set_read_params(65535, 2048);
@@ -67,17 +64,6 @@ async fn main() -> std::io::Result<()> {
6764
.payload_read_rate(Seconds::ZERO, Seconds::ZERO, 0)
6865
.h1(web::App::new().service(json).service(plaintext).finish())
6966
})?
70-
.configure(move |cfg| {
71-
let cores = cores.clone();
72-
cfg.on_worker_start(move |_| {
73-
if let Some(core) = cores.lock().unwrap().pop() {
74-
core_affinity::set_for_current(core);
75-
}
76-
Ready::<_, &str>::Ok(())
77-
});
78-
Ok(())
79-
})?
80-
.workers(total_cores)
8167
.run()
8268
.await
8369
}

frameworks/Rust/ntex/src/main_db.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use ntex::http::header::{CONTENT_TYPE, SERVER};
66
use ntex::http::{HttpService, KeepAlive, Request, Response, StatusCode};
77
use ntex::service::{Service, ServiceCtx, ServiceFactory};
88
use ntex::web::{Error, HttpResponse};
9-
use ntex::{time::Seconds, util::PoolId, util::Ready};
9+
use ntex::{time::Seconds, util::PoolId};
1010

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

85-
let cores = core_affinity::get_core_ids().unwrap();
86-
let total_cores = cores.len();
87-
let cores = std::sync::Arc::new(std::sync::Mutex::new(cores));
88-
8985
ntex::server::build()
9086
.backlog(1024)
87+
.enable_affinity()
9188
.bind("techempower", "0.0.0.0:8080", |cfg| {
9289
cfg.memory_pool(PoolId::P1);
9390
PoolId::P1.set_read_params(65535, 2048);
@@ -100,17 +97,6 @@ async fn main() -> std::io::Result<()> {
10097
.payload_read_rate(Seconds::ZERO, Seconds::ZERO, 0)
10198
.h1(AppFactory)
10299
})?
103-
.configure(move |cfg| {
104-
let cores = cores.clone();
105-
cfg.on_worker_start(move |_| {
106-
if let Some(core) = cores.lock().unwrap().pop() {
107-
core_affinity::set_for_current(core);
108-
}
109-
Ready::<_, &str>::Ok(())
110-
});
111-
Ok(())
112-
})?
113-
.workers(total_cores)
114100
.run()
115101
.await
116102
}

0 commit comments

Comments
 (0)