This is a butchered version of pg_prefaulter, developed by Joyent / @sean-.
Metrics have been removed, go modules added and some minor edits to the code made to pass staticcheck linting.
To build,
go build -o pg_prefaulter main.go
Please see the original README for motivation and further usage instructions.
-
Fixed an issue where in pg10+, the code would attempt to prefault files just ahead of the WAL files most recently received, instead of files just ahead of latest WAL files most recently replayed.
-
Using an Intel Optane device, I seem to get best results with a small number of IO threads.
-
I see regular errors due to SQL conflicts with recovery. WAL prefetch would be much better handled inside postgres itself. They're thinking about it, but it seems it won't land until at least pg15.
-
There is a version which uses
posix_fadvise()
instead ofpread()
on the 2021-07/posix_fadvise branch. Unfortunately, it turns out that ZFS does not actually supportposix_fadvise()
.