Skip to content

Commit dfe5e31

Browse files
abonandermehcode
authored andcommitted
perf: document sqlx-bench and pool fairness benchmark
1 parent e2c707b commit dfe5e31

16 files changed

+871
-0
lines changed

sqlx-bench/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
SQLx Self-Benchmarks
2+
====================
3+
4+
This Cargo project implements various benchmarks for SQLx using
5+
[Criterion](https://crates.io/crates/criterion).
6+
7+
### Available Benchmarks
8+
9+
* Group `pg_pool`: benchmarks `sqlx::Pool` against a PostgreSQL server.
10+
* `DATABASE_URL` must be set (or in `.env`) pointing to a PostgreSQL server.
11+
It should preferably be running on the same machine as the benchmarks to reduce latency.
12+
* The `postgres` feature must be enabled for this benchmark to run.
13+
* Benchmarks:
14+
* `bench_pgpool_acquire`: benchmarks `Pool::acquire()` when many concurrent tasks are also using
15+
the pool, with or without the pool being fair. Concurrently to the benchmark iteration
16+
function calling and blocking on `Pool::acquire()`, a varying number of background tasks are
17+
also calling `acquire()` and holding the acquired connection for 500µs each before releasing
18+
it back to the pool. The pool is created with `.min_size(50).max_size(50)` so we shouldn't
19+
be measuring anything but the actual overhead of `Pool`'s bookeeping.
20+
21+
### Running
22+
23+
You must choose a runtime to execute the benchmarks on; the feature flags are the same as the `sqlx` crate:
24+
25+
```bash
26+
cargo bench --features runtime-tokio
27+
cargo bench --features runtime-async-std
28+
```
29+
30+
When complete, the benchmark results will be in `target/criterion/`.
31+
Open `target/criterion/report/index.html` or pick one of the benchmark subfolders and open
32+
`report/index.html` there to view the results.
33+
34+
Benchmark Results
35+
-------
36+
37+
If you want to share the results here, please follow the format below.
38+
39+
* [2020/07/01: `pg_pool` benchmark added to test pool fairness changes](results/2020-07-01-bench_pgpool_acquire/REPORT.md)
Lines changed: 64 additions & 0 deletions
Loading
Lines changed: 68 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)