Browse Source

[ntex]: add io-uring based runtime (#9659)

* [ntex]: add io-uring runtime

* wip

* wip
Nikolay Kim 5 months ago
parent
commit
41ef0636a9

+ 16 - 2
frameworks/Rust/ntex/Cargo.toml

@@ -15,6 +15,10 @@ path = "src/main.rs"
 name = "ntex-neon"
 name = "ntex-neon"
 path = "src/main.rs"
 path = "src/main.rs"
 
 
+[[bin]]
+name = "ntex-neon-uring"
+path = "src/main.rs"
+
 [[bin]]
 [[bin]]
 name = "ntex-db"
 name = "ntex-db"
 path = "src/main_db.rs"
 path = "src/main_db.rs"
@@ -27,6 +31,10 @@ path = "src/main_db.rs"
 name = "ntex-db-neon"
 name = "ntex-db-neon"
 path = "src/main_db.rs"
 path = "src/main_db.rs"
 
 
+[[bin]]
+name = "ntex-db-neon-uring"
+path = "src/main_db.rs"
+
 [[bin]]
 [[bin]]
 name = "ntex-plt"
 name = "ntex-plt"
 path = "src/main_plt.rs"
 path = "src/main_plt.rs"
@@ -39,6 +47,10 @@ path = "src/main_plt.rs"
 name = "ntex-plt-neon"
 name = "ntex-plt-neon"
 path = "src/main_plt.rs"
 path = "src/main_plt.rs"
 
 
+[[bin]]
+name = "ntex-plt-neon-uring"
+path = "src/main_plt.rs"
+
 [features]
 [features]
 default = []
 default = []
 
 
@@ -51,6 +63,9 @@ compio = ["ntex/compio"]
 # neon runtime
 # neon runtime
 neon = ["ntex/neon"]
 neon = ["ntex/neon"]
 
 
+# neon runtime
+neon-uring = ["ntex/neon-uring"]
+
 [dependencies]
 [dependencies]
 ntex = "2.12"
 ntex = "2.12"
 ntex-compio = "0.2"
 ntex-compio = "0.2"
@@ -63,7 +78,7 @@ env_logger = "0.11"
 nanorand = { version = "0.7", default-features = false, features = ["std", "wyrand", "tls"] }
 nanorand = { version = "0.7", default-features = false, features = ["std", "wyrand", "tls"] }
 atoi = "2.0"
 atoi = "2.0"
 futures = "0.3"
 futures = "0.3"
-sonic-rs = "0.3.16"
+sonic-rs = "0.4.0"
 serde = { version = "1", features = ["derive"] }
 serde = { version = "1", features = ["derive"] }
 serde_json = "1"
 serde_json = "1"
 log = { version = "0.4", features = ["release_max_level_off"] }
 log = { version = "0.4", features = ["release_max_level_off"] }
@@ -78,7 +93,6 @@ ntex = { git = "https://github.com/ntex-rs/ntex.git" }
 ntex-io = { 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-net = { git = "https://github.com/ntex-rs/ntex.git" }
 ntex-rt = { 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]
 [profile.release]
 opt-level = 3
 opt-level = 3

+ 12 - 12
frameworks/Rust/ntex/benchmark_config.json

@@ -19,7 +19,7 @@
         "notes": "",
         "notes": "",
         "versus": ""
         "versus": ""
     },
     },
-    "compio": {
+    "neon": {
         "json_url": "/json",
         "json_url": "/json",
         "plaintext_url": "/plaintext",
         "plaintext_url": "/plaintext",
         "port": 8080,
         "port": 8080,
@@ -33,11 +33,11 @@
         "webserver": "ntex",
         "webserver": "ntex",
         "os": "Linux",
         "os": "Linux",
         "database_os": "Linux",
         "database_os": "Linux",
-        "display_name": "ntex [compio]",
+        "display_name": "ntex [neon]",
         "notes": "",
         "notes": "",
         "versus": ""
         "versus": ""
     },
     },
-    "neon": {
+    "neon-uring": {
         "json_url": "/json",
         "json_url": "/json",
         "plaintext_url": "/plaintext",
         "plaintext_url": "/plaintext",
         "port": 8080,
         "port": 8080,
@@ -51,7 +51,7 @@
         "webserver": "ntex",
         "webserver": "ntex",
         "os": "Linux",
         "os": "Linux",
         "database_os": "Linux",
         "database_os": "Linux",
-        "display_name": "ntex [neon]",
+        "display_name": "ntex [neon(io-uring)]",
         "notes": "",
         "notes": "",
         "versus": ""
         "versus": ""
     },
     },
@@ -75,7 +75,7 @@
         "notes": "",
         "notes": "",
         "versus": ""
         "versus": ""
     },
     },
-    "db-compio": {
+    "db-neon": {
         "fortune_url": "/fortunes",
         "fortune_url": "/fortunes",
         "db_url": "/db",
         "db_url": "/db",
         "query_url": "/query?q=",
         "query_url": "/query?q=",
@@ -91,11 +91,11 @@
         "webserver": "ntex",
         "webserver": "ntex",
         "os": "Linux",
         "os": "Linux",
         "database_os": "Linux",
         "database_os": "Linux",
-        "display_name": "ntex [compio,db]",
+        "display_name": "ntex [neon,db]",
         "notes": "",
         "notes": "",
         "versus": ""
         "versus": ""
     },
     },
-    "db-neon": {
+    "db-neon-uring": {
         "fortune_url": "/fortunes",
         "fortune_url": "/fortunes",
         "db_url": "/db",
         "db_url": "/db",
         "query_url": "/query?q=",
         "query_url": "/query?q=",
@@ -111,7 +111,7 @@
         "webserver": "ntex",
         "webserver": "ntex",
         "os": "Linux",
         "os": "Linux",
         "database_os": "Linux",
         "database_os": "Linux",
-        "display_name": "ntex [neon,db]",
+        "display_name": "ntex [neon(io-uring),db]",
         "notes": "",
         "notes": "",
         "versus": ""
         "versus": ""
     },
     },
@@ -133,7 +133,7 @@
         "notes": "",
         "notes": "",
         "versus": ""
         "versus": ""
     },
     },
-    "plt-compio": {
+    "plt-neon": {
         "json_url": "/json",
         "json_url": "/json",
         "plaintext_url": "/plaintext",
         "plaintext_url": "/plaintext",
         "port": 8080,
         "port": 8080,
@@ -147,11 +147,11 @@
         "webserver": "ntex",
         "webserver": "ntex",
         "os": "Linux",
         "os": "Linux",
         "database_os": "Linux",
         "database_os": "Linux",
-        "display_name": "ntex [compio,platform]",
+        "display_name": "ntex [neon,platform]",
         "notes": "",
         "notes": "",
         "versus": ""
         "versus": ""
     },
     },
-    "plt-neon": {
+    "plt-neon-uring": {
         "json_url": "/json",
         "json_url": "/json",
         "plaintext_url": "/plaintext",
         "plaintext_url": "/plaintext",
         "port": 8080,
         "port": 8080,
@@ -165,7 +165,7 @@
         "webserver": "ntex",
         "webserver": "ntex",
         "os": "Linux",
         "os": "Linux",
         "database_os": "Linux",
         "database_os": "Linux",
-        "display_name": "ntex [neon,platform]",
+        "display_name": "ntex [neon(io-uring),platform]",
         "notes": "",
         "notes": "",
         "versus": ""
         "versus": ""
     }
     }

+ 41 - 0
frameworks/Rust/ntex/config.toml

@@ -40,6 +40,19 @@ platform = "None"
 webserver = "ntex"
 webserver = "ntex"
 versus = ""
 versus = ""
 
 
+[neon-uring]
+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]
 [db]
 urls.db = "/db"
 urls.db = "/db"
 urls.query = "/query?q="
 urls.query = "/query?q="
@@ -85,6 +98,21 @@ platform = "None"
 webserver = "ntex"
 webserver = "ntex"
 versus = ""
 versus = ""
 
 
+[db-neon-uring]
+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]
 [plt]
 urls.plaintext = "/plaintext"
 urls.plaintext = "/plaintext"
 urls.json = "/json"
 urls.json = "/json"
@@ -123,3 +151,16 @@ orm = "Raw"
 platform = "None"
 platform = "None"
 webserver = "ntex"
 webserver = "ntex"
 versus = ""
 versus = ""
+
+[plt-neon-uring]
+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 - 0
frameworks/Rust/ntex/ntex-db-neon-uring.dockerfile

@@ -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-uring"
+
+EXPOSE 8080
+
+CMD ./target/release/ntex-db-neon-uring

+ 16 - 0
frameworks/Rust/ntex/ntex-neon-uring.dockerfile

@@ -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-uring"
+
+EXPOSE 8080
+
+CMD ./target/release/ntex-neon-uring

+ 16 - 0
frameworks/Rust/ntex/ntex-plt-neon-uring.dockerfile

@@ -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-uring"
+
+EXPOSE 8080
+
+CMD ./target/release/ntex-plt-neon-uring

+ 2 - 1
frameworks/Rust/ntex/src/utils.rs

@@ -57,10 +57,11 @@ impl WriteExt for BytesWriter<'_> {
     }
     }
 
 
     #[inline(always)]
     #[inline(always)]
-    unsafe fn flush_len(&mut self, additional: usize) {
+    unsafe fn flush_len(&mut self, additional: usize) -> io::Result<()> {
         unsafe {
         unsafe {
             let new_len = self.0.len() + additional;
             let new_len = self.0.len() + additional;
             self.0.set_len(new_len);
             self.0.set_len(new_len);
         }
         }
+        Ok(())
     }
     }
 }
 }