Browse Source

[ntex] replace async-std with compio runtime (#9222)

* ntex: replace async-std with compio

* wip

* wip
Nikolay Kim 11 months ago
parent
commit
9e58d22fdf

+ 14 - 7
frameworks/Rust/ntex/Cargo.toml

@@ -1,5 +1,5 @@
 [package]
-name = "ntex"
+name = "ntex-bench"
 version = "2.0.0"
 edition = "2018"
 
@@ -8,7 +8,7 @@ name = "ntex"
 path = "src/main.rs"
 
 [[bin]]
-name = "ntex-astd"
+name = "ntex-compio"
 path = "src/main.rs"
 
 [[bin]]
@@ -16,7 +16,7 @@ name = "ntex-db"
 path = "src/main_db.rs"
 
 [[bin]]
-name = "ntex-db-astd"
+name = "ntex-db-compio"
 path = "src/main_db.rs"
 
 [[bin]]
@@ -24,7 +24,7 @@ name = "ntex-plt"
 path = "src/main_plt.rs"
 
 [[bin]]
-name = "ntex-plt-astd"
+name = "ntex-plt-compio"
 path = "src/main_plt.rs"
 
 [features]
@@ -33,11 +33,11 @@ default = []
 # tokio runtime
 tokio = ["ntex/tokio"]
 
-# async-std runtime
-async-std = ["ntex/async-std"]
+# compio runtime
+compio = ["ntex/compio"]
 
 [dependencies]
-ntex = "=2.1.0"
+ntex = "2.4"
 ntex-bytes = { version = "0.1.21", features=["simd"] }
 mimalloc = { version = "0.1.25", default-features = false }
 snmalloc-rs = { version = "0.3.3", features = ["native-cpu"] }
@@ -63,3 +63,10 @@ lto = "thin"
 debug = false
 incremental = false
 overflow-checks = false
+
+[patch.crates-io]
+ntex = { git = "https://github.com/ntex-rs/ntex.git", branch = "compio" }
+ntex-io = { git = "https://github.com/ntex-rs/ntex.git", branch = "compio" }
+ntex-rt = { git = "https://github.com/ntex-rs/ntex.git", branch = "compio" }
+ntex-net = { git = "https://github.com/ntex-rs/ntex.git", branch = "compio" }
+ntex-compio = { git = "https://github.com/ntex-rs/ntex.git", branch = "compio" }

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

@@ -19,7 +19,7 @@
         "notes": "",
         "versus": ""
     },
-    "astd": {
+    "compio": {
         "json_url": "/json",
         "plaintext_url": "/plaintext",
         "port": 8080,
@@ -33,7 +33,7 @@
         "webserver": "ntex",
         "os": "Linux",
         "database_os": "Linux",
-        "display_name": "ntex [async-std]",
+        "display_name": "ntex [compio]",
         "notes": "",
         "versus": ""
     },
@@ -57,7 +57,7 @@
         "notes": "",
         "versus": ""
     },
-    "db-astd": {
+    "db-compio": {
         "fortune_url": "/fortunes",
         "db_url": "/db",
         "query_url": "/query?q=",
@@ -73,7 +73,7 @@
         "webserver": "ntex",
         "os": "Linux",
         "database_os": "Linux",
-        "display_name": "ntex [async-std,db]",
+        "display_name": "ntex [compio,db]",
         "notes": "",
         "versus": ""
     },
@@ -95,7 +95,7 @@
         "notes": "",
         "versus": ""
     },
-    "plt-astd": {
+    "plt-compio": {
         "json_url": "/json",
         "plaintext_url": "/plaintext",
         "port": 8080,
@@ -109,7 +109,7 @@
         "webserver": "ntex",
         "os": "Linux",
         "database_os": "Linux",
-        "display_name": "ntex [async-std,platform]",
+        "display_name": "ntex [compio,platform]",
         "notes": "",
         "versus": ""
     }

+ 3 - 3
frameworks/Rust/ntex/config.toml

@@ -14,7 +14,7 @@ platform = "None"
 webserver = "ntex"
 versus = ""
 
-[astd]
+[compio]
 urls.plaintext = "/plaintext"
 urls.json = "/json"
 approach = "Realistic"
@@ -42,7 +42,7 @@ platform = "None"
 webserver = "ntex"
 versus = ""
 
-[db-astd]
+[db-compio]
 urls.db = "/db"
 urls.query = "/query?q="
 urls.update = "/update?q="
@@ -70,7 +70,7 @@ platform = "None"
 webserver = "ntex"
 versus = ""
 
-[plt-astd]
+[plt-compio]
 urls.plaintext = "/plaintext"
 urls.json = "/json"
 approach = "Realistic"

+ 2 - 2
frameworks/Rust/ntex/ntex-astd.dockerfile → frameworks/Rust/ntex/ntex-compio.dockerfile

@@ -9,8 +9,8 @@ ADD ./ /ntex
 WORKDIR /ntex
 
 RUN cargo clean
-RUN RUSTFLAGS="-C target-cpu=native" cargo build --release --features="async-std"
+RUN RUSTFLAGS="-C target-cpu=native" cargo build --release --features="compio"
 
 EXPOSE 8080
 
-CMD ./target/release/ntex-astd
+CMD ./target/release/ntex-compio

+ 2 - 2
frameworks/Rust/ntex/ntex-db-astd.dockerfile → frameworks/Rust/ntex/ntex-db-compio.dockerfile

@@ -9,8 +9,8 @@ ADD ./ /ntex
 WORKDIR /ntex
 
 RUN cargo clean
-RUN RUSTFLAGS="-C target-cpu=native" cargo build --release --features="async-std"
+RUN RUSTFLAGS="-C target-cpu=native" cargo build --release --features="compio"
 
 EXPOSE 8080
 
-CMD ./target/release/ntex-db-astd
+CMD ./target/release/ntex-db-compio

+ 2 - 2
frameworks/Rust/ntex/ntex-plt-astd.dockerfile → frameworks/Rust/ntex/ntex-plt-compio.dockerfile

@@ -9,8 +9,8 @@ ADD ./ /ntex
 WORKDIR /ntex
 
 RUN cargo clean
-RUN RUSTFLAGS="-C target-cpu=native" cargo build --release --features="async-std"
+RUN RUSTFLAGS="-C target-cpu=native" cargo build --release --features="compio"
 
 EXPOSE 8080
 
-CMD ./target/release/ntex-plt-astd
+CMD ./target/release/ntex-plt-compio

+ 0 - 1
frameworks/Rust/ntex/src/main.rs

@@ -1,6 +1,5 @@
 #[global_allocator]
 static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
-// static GLOBAL: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
 
 use ntex::http::header::{CONTENT_TYPE, SERVER};
 use ntex::{http, time::Seconds, util::BytesMut, util::PoolId, web};

+ 1 - 1
frameworks/Rust/ntex/src/main_plt.rs

@@ -1,5 +1,5 @@
 #[global_allocator]
-static GLOBAL: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
+static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
 
 use std::{future::Future, io, pin::Pin, task::Context, task::Poll};