Skip to content

Commit 0b97f1e

Browse files
authored
[xitca-web] fix diesel update bench (#10429)
* [xitca-web] fix diesel update bench * module clean up. resolve majority of dead code * improve toasty perf
1 parent 55ad1a8 commit 0b97f1e

File tree

8 files changed

+217
-196
lines changed

8 files changed

+217
-196
lines changed

frameworks/Rust/xitca-web/Cargo.lock

Lines changed: 31 additions & 29 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: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ codegen-units = 1
9898
panic = "abort"
9999

100100
[patch.crates-io]
101-
xitca-postgres-diesel = { git = "https://github.com/fakeshadow/xitca-postgres-diesel", rev = "1bd39ac" }
102-
xitca-postgres-toasty = { git = "https://github.com/fakeshadow/xitca-postgres-toasty", rev = "270fe35" }
101+
xitca-postgres-diesel = { git = "https://github.com/fakeshadow/xitca-postgres-diesel", rev = "b6d1922" }
102+
xitca-postgres-toasty = { git = "https://github.com/fakeshadow/xitca-postgres-toasty", rev = "6034a22" }
103103

104104
toasty = { git = "https://github.com/fakeshadow/toasty", branch = "engine" }
105105
toasty-core = { git = "https://github.com/fakeshadow/toasty", branch = "engine" }
@@ -108,9 +108,9 @@ toasty-sql = { git = "https://github.com/fakeshadow/toasty", branch = "engine" }
108108
# personal fork of tokio-uring with tokio local runtime enabled
109109
tokio-uring = { git = "http://github.com/fakeshadow/tokio-uring", rev = "c3d5887" }
110110

111-
xitca-codegen = { git = "http://github.com/HFQR/xitca-web", rev = "faf1ae2" }
112-
xitca-http = { git = "http://github.com/HFQR/xitca-web", rev = "faf1ae2" }
113-
xitca-postgres = { git = "http://github.com/HFQR/xitca-web", rev = "faf1ae2" }
114-
xitca-server = { git = "http://github.com/HFQR/xitca-web", rev = "faf1ae2" }
115-
xitca-service = { git = "http://github.com/HFQR/xitca-web", rev = "faf1ae2" }
116-
xitca-web = { git = "http://github.com/HFQR/xitca-web", rev = "faf1ae2" }
111+
xitca-codegen = { git = "http://github.com/HFQR/xitca-web", rev = "3f38156" }
112+
xitca-http = { git = "http://github.com/HFQR/xitca-web", rev = "3f38156" }
113+
xitca-postgres = { git = "http://github.com/HFQR/xitca-web", rev = "3f38156" }
114+
xitca-server = { git = "http://github.com/HFQR/xitca-web", rev = "3f38156" }
115+
xitca-service = { git = "http://github.com/HFQR/xitca-web", rev = "3f38156" }
116+
xitca-web = { git = "http://github.com/HFQR/xitca-web", rev = "3f38156" }

frameworks/Rust/xitca-web/benchmark_config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"db_url": "/db",
5151
"fortune_url": "/fortunes",
5252
"query_url": "/queries?q=",
53+
"update_url": "/updates?q=",
5354
"port": 8080,
5455
"approach": "realistic",
5556
"classification": "fullstack",

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ pub struct Exec {
2525
impl Exec {
2626
pub const FORTUNE_STMT: StatementNamed<'_> = Statement::named("SELECT id,message FROM fortune", &[]);
2727
pub const WORLD_STMT: StatementNamed<'_> =
28-
Statement::named("SELECT id,randomnumber FROM world WHERE id=$1", &[Type::INT4]);
28+
Statement::named("SELECT id,randomNumber FROM world WHERE id=$1", &[Type::INT4]);
2929
pub const UPDATE_STMT: StatementNamed<'_> = Statement::named(
30-
"UPDATE world SET randomnumber=w.r FROM (SELECT unnest($1) as i,unnest($2) as r) w WHERE world.id=w.i",
30+
"UPDATE world SET randomNumber=w.r FROM (SELECT unnest($1) as i,unnest($2) as r) w WHERE world.id=w.i",
3131
&[Type::INT4_ARRAY, Type::INT4_ARRAY],
3232
);
3333

@@ -92,7 +92,7 @@ impl Exec {
9292
})
9393
.collect::<(Vec<_>, Vec<_>, Vec<_>)>();
9494

95-
let update = update_stmt.bind([&ids, &rngs]).query(&conn);
95+
let update = update_stmt.bind([&ids, &rngs]).execute(&conn);
9696

9797
drop(conn);
9898

@@ -119,7 +119,7 @@ impl Exec {
119119
let mut fortunes = Vec::with_capacity(16);
120120

121121
while let Some(row) = res.try_next().await? {
122-
fortunes.push(Fortune::new(row.get(0), row.get::<String>(1)));
122+
fortunes.push(Fortune::new(row.get(0), row.get_zc(1)));
123123
}
124124

125125
Ok(Fortunes::new(fortunes))

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ pub struct Client {
2121

2222
impl Client {
2323
pub async fn create() -> HandleResult<Self> {
24-
let (cli, mut drv) = xitca_postgres::Postgres::new(DB_URL).connect().await?;
24+
let (cli, drv) = xitca_postgres::Postgres::new(DB_URL).connect().await?;
25+
26+
let mut drv = drv.try_into_tcp().expect("raw tcp is used for database connection");
2527

2628
tokio::task::spawn(async move {
2729
while drv.try_next().await?.is_some() {}

0 commit comments

Comments
 (0)