Skip to content

Instantly share code, notes, and snippets.

@pklaus
Last active March 12, 2020 15:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pklaus/e711fb9b9672a3135d90d768d7696ac7 to your computer and use it in GitHub Desktop.
Save pklaus/e711fb9b9672a3135d90d768d7696ac7 to your computer and use it in GitHub Desktop.
PostgreSQL Benchmarks with pgbench and pg_test_fsync on an Intel Optane 900P 480GB PCIe SSD (where the PostgreSQL instance is running in a Docker container with the PGDATA volume and the Docker image store located on the Optane SSD)
$ uname -a
Linux 5fc03a999611 4.15.3-2-ARCH #1 SMP PREEMPT Thu Feb 15 00:13:49 UTC 2018 x86_64 Linux
$ cat /etc/issue
Welcome to Alpine Linux 3.6
Kernel \r on an \m (\l)
$ pg_config --version
PostgreSQL 10.1
$ cd /var/lib/postgresql/data/
$ pg_test_fsync
5 seconds per test
O_DIRECT supported on this platform for open_datasync and open_sync.
Compare file sync methods using one 8kB write:
(in wal_sync_method preference order, except fdatasync is Linux's default)
open_datasync 33658.059 ops/sec 30 usecs/op
fdatasync 32739.266 ops/sec 31 usecs/op
fsync 30190.285 ops/sec 33 usecs/op
fsync_writethrough n/a
open_sync 30939.870 ops/sec 32 usecs/op
Compare file sync methods using two 8kB writes:
(in wal_sync_method preference order, except fdatasync is Linux's default)
open_datasync 20151.027 ops/sec 50 usecs/op
fdatasync 21399.872 ops/sec 47 usecs/op
fsync 20932.908 ops/sec 48 usecs/op
fsync_writethrough n/a
open_sync 19837.057 ops/sec 50 usecs/op
Compare open_sync with different write sizes:
(This is designed to compare the cost of writing 16kB in different write
open_sync sizes.)
1 * 16kB open_sync write 25223.839 ops/sec 40 usecs/op
2 * 8kB open_sync writes 19772.462 ops/sec 51 usecs/op
4 * 4kB open_sync writes 10238.681 ops/sec 98 usecs/op
8 * 2kB open_sync writes 3439.561 ops/sec 291 usecs/op
16 * 1kB open_sync writes 1603.666 ops/sec 624 usecs/op
Test if fsync on non-write file descriptor is honored:
(If the times are similar, fsync() can sync data written on a different
descriptor.)
write, fsync, close 26943.298 ops/sec 37 usecs/op
write, close, fsync 27315.274 ops/sec 37 usecs/op
Non-sync'ed 8kB writes:
write 365758.683 ops/sec 3 usecs/op
$ uname -a
Linux 5fc03a999611 4.15.3-2-ARCH #1 SMP PREEMPT Thu Feb 15 00:13:49 UTC 2018 x86_64 Linux
$ cat /etc/issue
Welcome to Alpine Linux 3.6
Kernel \r on an \m (\l)
$ pg_config --version
PostgreSQL 10.1
$ pgbench -i -h localhost -p 5432 -U postgres -s 25
$ pgbench -h localhost -p 5432 -U postgres -t 1000
starting vacuum...end.
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 1
query mode: simple
number of clients: 1
number of threads: 1
number of transactions per client: 1000
number of transactions actually processed: 1000/1000
latency average = 0.362 ms
tps = 2759.622825 (including connections establishing)
tps = 2767.974113 (excluding connections establishing)
$ pgbench -h localhost -p 5432 -U postgres -t 1000
starting vacuum...end.
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 1
query mode: simple
number of clients: 90
number of threads: 1
number of transactions per client: 20
number of transactions actually processed: 1800/1800
latency average = 31.331 ms
tps = 2872.539308 (including connections establishing)
tps = 2880.832617 (excluding connections establishing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment