Pārlūkot izejas kodu

ntex: update version

Nikolay Kim 6 mēneši atpakaļ
vecāks
revīzija
174292e133

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

@@ -11,6 +11,10 @@ path = "src/main.rs"
 name = "ntex-compio"
 path = "src/main.rs"
 
+[[bin]]
+name = "ntex-default"
+path = "src/main.rs"
+
 [[bin]]
 name = "ntex-db"
 path = "src/main_db.rs"
@@ -19,6 +23,10 @@ path = "src/main_db.rs"
 name = "ntex-db-compio"
 path = "src/main_db.rs"
 
+[[bin]]
+name = "ntex-db-default"
+path = "src/main_db.rs"
+
 [[bin]]
 name = "ntex-plt"
 path = "src/main_plt.rs"
@@ -27,6 +35,10 @@ path = "src/main_plt.rs"
 name = "ntex-plt-compio"
 path = "src/main_plt.rs"
 
+[[bin]]
+name = "ntex-plt-default"
+path = "src/main_plt.rs"
+
 [features]
 default = []
 
@@ -36,8 +48,11 @@ tokio = ["ntex/tokio"]
 # compio runtime
 compio = ["ntex/compio"]
 
+# default-rt runtime
+default-rt = ["ntex/default-rt"]
+
 [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 }
@@ -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"] }
@@ -59,6 +73,14 @@ 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-iodriver = { 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-runtime = { git = "https://github.com/ntex-rs/ntex.git" }
+
 [profile.release]
 opt-level = 3
 codegen-units = 1

+ 56 - 0
frameworks/Rust/ntex/benchmark_config.json

@@ -37,6 +37,24 @@
         "notes": "",
         "versus": ""
     },
+    "default": {
+        "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 [default]",
+        "notes": "",
+        "versus": ""
+    },
     "db": {
         "fortune_url": "/fortunes",
         "db_url": "/db",
@@ -77,6 +95,26 @@
         "notes": "",
         "versus": ""
     },
+    "db-default": {
+        "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 [default,db]",
+        "notes": "",
+        "versus": ""
+    },
     "plt": {
         "json_url": "/json",
         "plaintext_url": "/plaintext",
@@ -112,6 +150,24 @@
         "display_name": "ntex [compio,platform]",
         "notes": "",
         "versus": ""
+    },
+    "plt-default": {
+        "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 [default,platform]",
+        "notes": "",
+        "versus": ""
     }
   }]
 }

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

@@ -27,6 +27,19 @@ platform = "None"
 webserver = "ntex"
 versus = ""
 
+[default]
+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="
@@ -57,6 +70,21 @@ platform = "None"
 webserver = "ntex"
 versus = ""
 
+[db-default]
+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"
@@ -82,3 +110,16 @@ orm = "Raw"
 platform = "None"
 webserver = "ntex"
 versus = ""
+
+[plt-default]
+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-default.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="default-rt"
+
+EXPOSE 8080
+
+CMD ./target/release/ntex-db-default

+ 16 - 0
frameworks/Rust/ntex/ntex-default.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="default-rt"
+
+EXPOSE 8080
+
+CMD ./target/release/ntex-default

+ 16 - 0
frameworks/Rust/ntex/ntex-plt-default.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="default"
+
+EXPOSE 8080
+
+CMD ./target/release/ntex-plt-default

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

@@ -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);
@@ -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
 }

+ 1 - 15
frameworks/Rust/ntex/src/main_db.rs

@@ -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);
@@ -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
 }

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

@@ -79,13 +79,10 @@ impl Future for App {
 async fn main() -> 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);
@@ -96,17 +93,6 @@ async fn main() -> io::Result<()> {
                 codec: h1::Codec::default(),
             })
         })?
-        .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
 }