Skip to content

Commit 496a8ec

Browse files
authored
[xitca-web] strict thread-per-core (#9399)
* use core affinity for static thread per core * use strict thread per core pattern * dep update * dep update
1 parent f8a7664 commit 496a8ec

File tree

4 files changed

+133
-107
lines changed

4 files changed

+133
-107
lines changed

frameworks/Rust/xitca-web/Cargo.lock

Lines changed: 60 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frameworks/Rust/xitca-web/Cargo.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ template = ["dep:sailfish"]
4646
# io-uring optional
4747
io-uring = ["dep:tokio-uring", "xitca-http/io-uring", "xitca-server/io-uring"]
4848
# unrealistic performance optimization
49-
perf = ["dep:mimalloc", "tokio/parking_lot"]
49+
perf = ["dep:core_affinity", "dep:mimalloc", "tokio/parking_lot"]
5050

5151
[dependencies]
5252
xitca-http = "0.7"
@@ -81,13 +81,14 @@ sailfish = { version = "0.9", default-features = false, features = ["perf-inline
8181
tokio-uring = { version = "0.5", optional = true }
8282

8383
# perf optional
84+
core_affinity = { version = "0.8.1", optional = true }
8485
mimalloc = { version = "0.1", default-features = false, optional = true }
8586

8687
# stuff can not be used or not needed in wasi target
8788
[target.'cfg(not(target_family = "wasm"))'.dependencies]
8889
futures-core = { version = "0.3", default-features = false }
8990
rand = { version = "0.8", features = ["small_rng"] }
90-
tokio = "1"
91+
tokio = "1.41"
9192

9293
[profile.release]
9394
lto = true
@@ -100,11 +101,10 @@ xitca-postgres-diesel = { git = "https://github.com/fakeshadow/xitca-postgres-di
100101

101102
diesel-async = { git = "https://github.com/weiznich/diesel_async", rev = "5b8262b" }
102103
mio = { git = "https://github.com/fakeshadow/mio", rev = "9bae6012b7ecfc6083350785f71a5e8265358178" }
103-
tokio = { git = "https://github.com/tokio-rs/tokio.git", rev = "512e9de" }
104-
105-
xitca-codegen = { git = "http://github.com/HFQR/xitca-web", rev = "1de8d9c" }
106-
xitca-http = { git = "http://github.com/HFQR/xitca-web", rev = "1de8d9c" }
107-
xitca-postgres = { git = "http://github.com/HFQR/xitca-web", rev = "1de8d9c" }
108-
xitca-server = { git = "http://github.com/HFQR/xitca-web", rev = "1de8d9c" }
109-
xitca-service = { git = "http://github.com/HFQR/xitca-web", rev = "1de8d9c" }
110-
xitca-web = { git = "http://github.com/HFQR/xitca-web", rev = "1de8d9c" }
104+
105+
xitca-codegen = { git = "http://github.com/HFQR/xitca-web", rev = "3b005af" }
106+
xitca-http = { git = "http://github.com/HFQR/xitca-web", rev = "3b005af" }
107+
xitca-postgres = { git = "http://github.com/HFQR/xitca-web", rev = "3b005af" }
108+
xitca-server = { git = "http://github.com/HFQR/xitca-web", rev = "3b005af" }
109+
xitca-service = { git = "http://github.com/HFQR/xitca-web", rev = "3b005af" }
110+
xitca-web = { git = "http://github.com/HFQR/xitca-web", rev = "3b005af" }

frameworks/Rust/xitca-web/src/main.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,12 @@ where
5151
#[cold]
5252
#[inline(never)]
5353
fn error_handler(e: RouterError<util::Error>) -> Response {
54-
match e {
55-
RouterError::Match(_) => error_response(StatusCode::NOT_FOUND),
56-
RouterError::NotAllowed(_) => error_response(StatusCode::METHOD_NOT_ALLOWED),
57-
RouterError::Service(e) => {
58-
println!("{e}");
59-
error_response(StatusCode::INTERNAL_SERVER_ERROR)
60-
}
61-
}
54+
let status = match e {
55+
RouterError::Match(_) => StatusCode::NOT_FOUND,
56+
RouterError::NotAllowed(_) => StatusCode::METHOD_NOT_ALLOWED,
57+
RouterError::Service(_) => StatusCode::INTERNAL_SERVER_ERROR,
58+
};
59+
error_response(status)
6260
}
6361

6462
async fn plain_text(ctx: Ctx<'_>) -> HandleResult<Response> {

0 commit comments

Comments
 (0)