sqlx/sqlx-bench
Yuri Astrakhan a824e8468c
Cleanup format arguments (#2650)
Inlined format args make code more readable, and code more compact.

I ran this clippy command to fix most cases, and then cleaned up a few trailing commas and uncaught edge cases.

```
cargo clippy --bins --examples  --benches --tests --lib --workspace --fix -- -A clippy::all -W clippy::uninlined_format_args
```
2023-07-31 13:27:04 -07:00
..
benches Cleanup format arguments (#2650) 2023-07-31 13:27:04 -07:00
results/2020-07-01-bench_pgpool_acquire perf: document sqlx-bench and pool fairness benchmark 2020-07-03 05:59:20 -07:00
Cargo.toml 0.7.0-alpha.1 release 2023-02-21 14:56:54 -08:00
README.md Fix typos (#1894) 2022-06-08 14:56:56 -07:00
test.db feat: implement testing utilities (#2001) 2022-08-02 14:38:12 -07:00

SQLx Self-Benchmarks

This Cargo project implements various benchmarks for SQLx using Criterion.

Available Benchmarks

  • Group pg_pool: benchmarks sqlx::Pool against a PostgreSQL server.
    • DATABASE_URL must be set (or in .env) pointing to a PostgreSQL server. It should preferably be running on the same machine as the benchmarks to reduce latency.
    • The postgres feature must be enabled for this benchmark to run.
    • Benchmarks:
      • bench_pgpool_acquire: benchmarks Pool::acquire() when many concurrent tasks are also using the pool, with or without the pool being fair. Concurrently to the benchmark iteration function calling and blocking on Pool::acquire(), a varying number of background tasks are also calling acquire() and holding the acquired connection for 500µs each before releasing it back to the pool. The pool is created with .min_connections(50).max_connections(50) so we shouldn't be measuring anything but the actual overhead of Pool's bookkeeping.

Running

You must choose a runtime to execute the benchmarks on; the feature flags are the same as the sqlx crate:

cargo bench --features runtime-tokio-native-tls
cargo bench --features runtime-async-std-rustls

When complete, the benchmark results will be in target/criterion/. Open target/criterion/report/index.html or pick one of the benchmark subfolders and open report/index.html there to view the results.

Benchmark Results

If you want to share the results here, please follow the format below.