Skip to content

Instantly share code, notes, and snippets.

@pklaus
Created June 3, 2018 21:07
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/2606aae92a8a248d9f2171c7e1c76e45 to your computer and use it in GitHub Desktop.
Save pklaus/2606aae92a8a248d9f2171c7e1c76e45 to your computer and use it in GitHub Desktop.
PostgreSQL Benchmarks with pg_test_fsync on a Samsung 970 Evo 1TB PCIe M.2 2280 SSD
$ uname -a
Linux jay 4.16.12-1-ARCH #1 SMP PREEMPT Fri May 25 23:30:31 UTC 2018 x86_64 GNU/Linux
$ cat /etc/issue
Arch Linux \r (\l)
$ pg_config --version
PostgreSQL 10.4
$ cd /var/lib/postgres/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 958.857 ops/sec 1043 usecs/op
fdatasync 947.106 ops/sec 1056 usecs/op
fsync 318.890 ops/sec 3136 usecs/op
fsync_writethrough n/a
open_sync 320.771 ops/sec 3117 usecs/op
Compare file sync methods using two 8kB writes:
(in wal_sync_method preference order, except fdatasync is Linux's default)
open_datasync 478.650 ops/sec 2089 usecs/op
fdatasync 844.952 ops/sec 1183 usecs/op
fsync 310.101 ops/sec 3225 usecs/op
fsync_writethrough n/a
open_sync 159.392 ops/sec 6274 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 308.730 ops/sec 3239 usecs/op
2 * 8kB open_sync writes 157.142 ops/sec 6364 usecs/op
4 * 4kB open_sync writes 79.251 ops/sec 12618 usecs/op
8 * 2kB open_sync writes 39.022 ops/sec 25627 usecs/op
16 * 1kB open_sync writes 19.467 ops/sec 51368 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 373.968 ops/sec 2674 usecs/op
write, close, fsync 308.793 ops/sec 3238 usecs/op
Non-sync'ed 8kB writes:
write 436554.851 ops/sec 2 usecs/op
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment