Skip to content

Commit 41ef063

Browse files
authored
[ntex]: add io-uring based runtime (#9659)
* [ntex]: add io-uring runtime * wip * wip
1 parent 6dad79d commit 41ef063

7 files changed

+119
-15
lines changed

frameworks/Rust/ntex/Cargo.toml

+16-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ path = "src/main.rs"
1515
name = "ntex-neon"
1616
path = "src/main.rs"
1717

18+
[[bin]]
19+
name = "ntex-neon-uring"
20+
path = "src/main.rs"
21+
1822
[[bin]]
1923
name = "ntex-db"
2024
path = "src/main_db.rs"
@@ -27,6 +31,10 @@ path = "src/main_db.rs"
2731
name = "ntex-db-neon"
2832
path = "src/main_db.rs"
2933

34+
[[bin]]
35+
name = "ntex-db-neon-uring"
36+
path = "src/main_db.rs"
37+
3038
[[bin]]
3139
name = "ntex-plt"
3240
path = "src/main_plt.rs"
@@ -39,6 +47,10 @@ path = "src/main_plt.rs"
3947
name = "ntex-plt-neon"
4048
path = "src/main_plt.rs"
4149

50+
[[bin]]
51+
name = "ntex-plt-neon-uring"
52+
path = "src/main_plt.rs"
53+
4254
[features]
4355
default = []
4456

@@ -51,6 +63,9 @@ compio = ["ntex/compio"]
5163
# neon runtime
5264
neon = ["ntex/neon"]
5365

66+
# neon runtime
67+
neon-uring = ["ntex/neon-uring"]
68+
5469
[dependencies]
5570
ntex = "2.12"
5671
ntex-compio = "0.2"
@@ -63,7 +78,7 @@ env_logger = "0.11"
6378
nanorand = { version = "0.7", default-features = false, features = ["std", "wyrand", "tls"] }
6479
atoi = "2.0"
6580
futures = "0.3"
66-
sonic-rs = "0.3.16"
81+
sonic-rs = "0.4.0"
6782
serde = { version = "1", features = ["derive"] }
6883
serde_json = "1"
6984
log = { version = "0.4", features = ["release_max_level_off"] }
@@ -78,7 +93,6 @@ ntex = { git = "https://github.com/ntex-rs/ntex.git" }
7893
ntex-io = { git = "https://github.com/ntex-rs/ntex.git" }
7994
ntex-net = { git = "https://github.com/ntex-rs/ntex.git" }
8095
ntex-rt = { git = "https://github.com/ntex-rs/ntex.git" }
81-
ntex-neon = { git = "https://github.com/ntex-rs/ntex.git" }
8296

8397
[profile.release]
8498
opt-level = 3

frameworks/Rust/ntex/benchmark_config.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"notes": "",
2020
"versus": ""
2121
},
22-
"compio": {
22+
"neon": {
2323
"json_url": "/json",
2424
"plaintext_url": "/plaintext",
2525
"port": 8080,
@@ -33,11 +33,11 @@
3333
"webserver": "ntex",
3434
"os": "Linux",
3535
"database_os": "Linux",
36-
"display_name": "ntex [compio]",
36+
"display_name": "ntex [neon]",
3737
"notes": "",
3838
"versus": ""
3939
},
40-
"neon": {
40+
"neon-uring": {
4141
"json_url": "/json",
4242
"plaintext_url": "/plaintext",
4343
"port": 8080,
@@ -51,7 +51,7 @@
5151
"webserver": "ntex",
5252
"os": "Linux",
5353
"database_os": "Linux",
54-
"display_name": "ntex [neon]",
54+
"display_name": "ntex [neon(io-uring)]",
5555
"notes": "",
5656
"versus": ""
5757
},
@@ -75,7 +75,7 @@
7575
"notes": "",
7676
"versus": ""
7777
},
78-
"db-compio": {
78+
"db-neon": {
7979
"fortune_url": "/fortunes",
8080
"db_url": "/db",
8181
"query_url": "/query?q=",
@@ -91,11 +91,11 @@
9191
"webserver": "ntex",
9292
"os": "Linux",
9393
"database_os": "Linux",
94-
"display_name": "ntex [compio,db]",
94+
"display_name": "ntex [neon,db]",
9595
"notes": "",
9696
"versus": ""
9797
},
98-
"db-neon": {
98+
"db-neon-uring": {
9999
"fortune_url": "/fortunes",
100100
"db_url": "/db",
101101
"query_url": "/query?q=",
@@ -111,7 +111,7 @@
111111
"webserver": "ntex",
112112
"os": "Linux",
113113
"database_os": "Linux",
114-
"display_name": "ntex [neon,db]",
114+
"display_name": "ntex [neon(io-uring),db]",
115115
"notes": "",
116116
"versus": ""
117117
},
@@ -133,7 +133,7 @@
133133
"notes": "",
134134
"versus": ""
135135
},
136-
"plt-compio": {
136+
"plt-neon": {
137137
"json_url": "/json",
138138
"plaintext_url": "/plaintext",
139139
"port": 8080,
@@ -147,11 +147,11 @@
147147
"webserver": "ntex",
148148
"os": "Linux",
149149
"database_os": "Linux",
150-
"display_name": "ntex [compio,platform]",
150+
"display_name": "ntex [neon,platform]",
151151
"notes": "",
152152
"versus": ""
153153
},
154-
"plt-neon": {
154+
"plt-neon-uring": {
155155
"json_url": "/json",
156156
"plaintext_url": "/plaintext",
157157
"port": 8080,
@@ -165,7 +165,7 @@
165165
"webserver": "ntex",
166166
"os": "Linux",
167167
"database_os": "Linux",
168-
"display_name": "ntex [neon,platform]",
168+
"display_name": "ntex [neon(io-uring),platform]",
169169
"notes": "",
170170
"versus": ""
171171
}

frameworks/Rust/ntex/config.toml

+41
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ platform = "None"
4040
webserver = "ntex"
4141
versus = ""
4242

43+
[neon-uring]
44+
urls.plaintext = "/plaintext"
45+
urls.json = "/json"
46+
approach = "Realistic"
47+
classification = "Micro"
48+
database = "Postgres"
49+
database_os = "Linux"
50+
os = "Linux"
51+
orm = "Raw"
52+
platform = "None"
53+
webserver = "ntex"
54+
versus = ""
55+
4356
[db]
4457
urls.db = "/db"
4558
urls.query = "/query?q="
@@ -85,6 +98,21 @@ platform = "None"
8598
webserver = "ntex"
8699
versus = ""
87100

101+
[db-neon-uring]
102+
urls.db = "/db"
103+
urls.query = "/query?q="
104+
urls.update = "/update?q="
105+
urls.fortune = "/fortunes"
106+
approach = "Realistic"
107+
classification = "Micro"
108+
database = "Postgres"
109+
database_os = "Linux"
110+
os = "Linux"
111+
orm = "Raw"
112+
platform = "None"
113+
webserver = "ntex"
114+
versus = ""
115+
88116
[plt]
89117
urls.plaintext = "/plaintext"
90118
urls.json = "/json"
@@ -123,3 +151,16 @@ orm = "Raw"
123151
platform = "None"
124152
webserver = "ntex"
125153
versus = ""
154+
155+
[plt-neon-uring]
156+
urls.plaintext = "/plaintext"
157+
urls.json = "/json"
158+
approach = "Realistic"
159+
classification = "Platform"
160+
database = "Postgres"
161+
database_os = "Linux"
162+
os = "Linux"
163+
orm = "Raw"
164+
platform = "None"
165+
webserver = "ntex"
166+
versus = ""
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-uring"
13+
14+
EXPOSE 8080
15+
16+
CMD ./target/release/ntex-db-neon-uring
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-uring"
13+
14+
EXPOSE 8080
15+
16+
CMD ./target/release/ntex-neon-uring
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-uring"
13+
14+
EXPOSE 8080
15+
16+
CMD ./target/release/ntex-plt-neon-uring

frameworks/Rust/ntex/src/utils.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ impl WriteExt for BytesWriter<'_> {
5757
}
5858

5959
#[inline(always)]
60-
unsafe fn flush_len(&mut self, additional: usize) {
60+
unsafe fn flush_len(&mut self, additional: usize) -> io::Result<()> {
6161
unsafe {
6262
let new_len = self.0.len() + additional;
6363
self.0.set_len(new_len);
6464
}
65+
Ok(())
6566
}
6667
}

0 commit comments

Comments
 (0)