Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Benchmarks] Add the WTX project #3879

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:

- name: Run Benchmarks (Postgres)
if: matrix.backend == 'postgres'
run: cargo +stable bench --manifest-path diesel_bench/Cargo.toml --no-default-features --features "postgres sqlx-bench sqlx/postgres rust_postgres futures sea-orm sea-orm/sqlx-postgres criterion/async_tokio quaint quaint/postgresql quaint/serde-support serde diesel-async diesel-async/postgres"
run: cargo +stable bench --manifest-path diesel_bench/Cargo.toml --no-default-features --features "postgres sqlx-bench sqlx/postgres rust_postgres futures sea-orm sea-orm/sqlx-postgres criterion/async_tokio quaint quaint/postgresql quaint/serde-support serde diesel-async diesel-async/postgres wtx"

- name: Run Benchmarks (Sqlite)
if: matrix.backend == 'sqlite'
Expand Down
1 change: 1 addition & 0 deletions diesel_bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ futures = {version = "0.3", optional = true}
diesel-async = {version = "0.4", optional = true, default-features = false}
criterion-perf-events = { version = "0.4", optional = true}
perfcnt = {version = "0.8", optional = true}
wtx = { default-features = false, features = ["atoi", "postgres", "simdutf8", "std", "tokio"], optional = true, version = "0.12" }

[dependencies.diesel]
path = "../diesel"
Expand Down
6 changes: 3 additions & 3 deletions diesel_bench/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and the following crates:
* [Rusqlite](https://github.com/rusqlite/rusqlite)
* [Mysql](https://github.com/blackbeam/rust-mysql-simple)
* [diesel-async](https://github.com/weiznich/diesel_async)
* [wtx](https://github.com/c410-f3r/wtx)

By default only diesels own benchmarks are executed. To run the benchmark do the following:

Expand All @@ -40,6 +41,7 @@ To enable other crates add the following features:
* `Rusqlite`: `rusqlite $backend`
* `Mysql`: `rust-mysql $backend`
* `diesel-async`: `diesel-async diesel-async/$backend $backend tokio`
* `wtx`: `$backend tokio/rt-multi-thread wtx`

## Benchmarks

Expand All @@ -48,6 +50,7 @@ To enable other crates add the following features:
#### Table definitions

The following schema definition was used. (For Mysql/Sqlite postgres specific types where replaced by their equivalent type).

```sql
CREATE TABLE users (
id SERIAL PRIMARY KEY,
Expand All @@ -67,10 +70,8 @@ CREATE TABLE comments (
post_id INTEGER NOT NULL,
text TEXT NOT NULL
);

```


#### Struct definitions

```rust
Expand Down Expand Up @@ -98,7 +99,6 @@ Field types are allowed to differ, to whatever type is expected compatible by th

### `bench_trivial_query`


This benchmark tests how entities from a single table are loaded. Before starting the benchmark 1, 10, 100, 1000 or 10000 entries are inserted into the `users` table. For this the `id` of the user is provided by the autoincrementing id, the `name` is set to `User {id}` and the `hair_color` is set to `Null`. An implementation of this benchmark is expected to return a list of the type `User.

### `bench_medium_complex_query`
Expand Down
22 changes: 22 additions & 0 deletions diesel_bench/benches/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ mod rust_orm_benches;
mod sea_orm_benches;
#[cfg(feature = "sqlx-bench")]
mod sqlx_benches;
#[cfg(feature = "wtx")]
mod wtx;

use criterion::{BenchmarkId, Criterion};

Expand Down Expand Up @@ -154,6 +156,11 @@ fn bench_trivial_query(c: &mut CriterionType) {
group.bench_with_input(BenchmarkId::new("sea-orm", size), size, |b, i| {
crate::sea_orm_benches::bench_trivial_query(b, *i);
});

#[cfg(all(feature = "postgres", feature = "wtx"))]
group.bench_with_input(BenchmarkId::new("wtx", size), size, |b, i| {
crate::wtx::bench_trivial_query(b, *i);
});
}

group.finish();
Expand Down Expand Up @@ -252,6 +259,11 @@ fn bench_medium_complex_query(c: &mut CriterionType) {
group.bench_with_input(BenchmarkId::new("sea-orm", size), size, |b, i| {
crate::sea_orm_benches::bench_medium_complex_query(b, *i);
});

#[cfg(all(feature = "postgres", feature = "wtx"))]
group.bench_with_input(BenchmarkId::new("wtx", size), size, |b, i| {
crate::wtx::bench_medium_complex_query(b, *i);
});
}

group.finish();
Expand Down Expand Up @@ -305,6 +317,11 @@ fn bench_loading_associations_sequentially(c: &mut CriterionType) {
crate::sea_orm_benches::loading_associations_sequentially(b);
});

#[cfg(feature = "wtx")]
group.bench_function("wtx", |b| {
crate::wtx::bench_loading_associations_sequentially(b);
});

group.finish();
}

Expand Down Expand Up @@ -355,6 +372,11 @@ fn bench_insert(c: &mut CriterionType) {
group.bench_with_input(BenchmarkId::new("sea-orm", size), size, |b, i| {
crate::sea_orm_benches::bench_insert(b, *i);
});

#[cfg(all(feature = "postgres", feature = "wtx"))]
group.bench_with_input(BenchmarkId::new("wtx", size), size, |b, i| {
crate::wtx::bench_insert(b, *i);
});
}

group.finish();
Expand Down
Loading