Skip to content

Instantly share code, notes, and snippets.

@pklaus
Created January 7, 2020 13:41
Show Gist options
  • Save pklaus/3f4756c3d1bd48fa960a558ce3103b6b to your computer and use it in GitHub Desktop.
Save pklaus/3f4756c3d1bd48fa960a558ce3103b6b to your computer and use it in GitHub Desktop.
Postgres / PostgreSQL Benchmarks with pg_test_fsync on a WDC WD2002FYPS-0 2TB SATA HDD (AMD Ryzen 3600X on X570 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 81.276 ops/sec 12304 usecs/op
fdatasync 81.940 ops/sec 12204 usecs/op
fsync 20.966 ops/sec 47696 usecs/op
fsync_writethrough n/a
open_sync 20.980 ops/sec 47665 usecs/op
Compare file sync methods using two 8kB writes:
(in wal_sync_method preference order, except fdatasync is Linux's default)
open_datasync 38.486 ops/sec 25983 usecs/op
fdatasync 78.133 ops/sec 12799 usecs/op
fsync 20.033 ops/sec 49918 usecs/op
fsync_writethrough n/a
open_sync 10.324 ops/sec 96862 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 20.785 ops/sec 48111 usecs/op
2 * 8kB open_sync writes 9.708 ops/sec 103004 usecs/op
4 * 4kB open_sync writes 5.138 ops/sec 194625 usecs/op
8 * 2kB open_sync writes 2.411 ops/sec 414803 usecs/op
16 * 1kB open_sync writes 1.293 ops/sec 773675 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 20.098 ops/sec 49756 usecs/op
write, close, fsync 19.812 ops/sec 50475 usecs/op
Non-sync'ed 8kB writes:
write 593734.369 ops/sec 2 usecs/op
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment