Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Postgres / PostgreSQL Benchmarks with pg_test_fsync on a 4-drive Raid 5 of WDC WD2002FYPS-0 2TB SATA HDDs (Intel i7-4770K and Intel Z87 Chipset)
$ uname -a
Linux owl 5.4.8-arch1-1 #1 SMP PREEMPT Sat, 04 Jan 2020 23:46:18 +0000 x86_64 GNU/Linux
$ cat /etc/issue
Arch Linux \r (\l)
$ pg_config --version
PostgreSQL 12.1
$ cd ~
$ 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 89.503 ops/sec 11173 usecs/op
fdatasync 86.933 ops/sec 11503 usecs/op
fsync 30.719 ops/sec 32553 usecs/op
fsync_writethrough n/a
open_sync 29.384 ops/sec 34032 usecs/op
Compare file sync methods using two 8kB writes:
(in wal_sync_method preference order, except fdatasync is Linux's default)
open_datasync 44.177 ops/sec 22636 usecs/op
fdatasync 88.999 ops/sec 11236 usecs/op
fsync 28.369 ops/sec 35249 usecs/op
fsync_writethrough n/a
open_sync 14.251 ops/sec 70168 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 29.645 ops/sec 33732 usecs/op
2 * 8kB open_sync writes 14.815 ops/sec 67498 usecs/op
4 * 4kB open_sync writes 7.247 ops/sec 137983 usecs/op
8 * 2kB open_sync writes 3.579 ops/sec 279445 usecs/op
16 * 1kB open_sync writes 1.866 ops/sec 535834 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
write, fsync, close 28.876 ops/sec 34631 usecs/op
write, close, fsync 29.316 ops/sec 34111 usecs/op
Non-sync'ed 8kB writes:
write 453549.074 ops/sec 2 usecs/op
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment