Use pg_pread() and pg_pwrite() for data files and WAL.
Thomas Munro <tmunro@postgresql.org>
Use pg_pread() and pg_pwrite() for data files and WAL. Cut down on system calls by doing random I/O using offset-based OS routines where available. Remove the code for tracking the 'virtual' seek position. The only reason left to call FileSeek() was to get the file's size, so provide a new function FileSize() instead. Author: Oskari Saarenmaa, Thomas Munro Reviewed-by: Thomas Munro, Jesper Pedersen, Tom Lane, Alvaro Herrera Discussion: https://postgr.es/m/CAEepm=02rapCpPR3ZGF2vW=SBHSdFYO_bz_f-wwWJonmA3APgw@mail.gmail.com Discussion: https://postgr.es/m/b8748d39-0b19-0514-a1b9-4e5a28e6a208%40gmail.com Discussion: https://postgr.es/m/a86bd200-ebbe-d829-e3ca-0c4474b2fcb7%40ohmu.fi
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/access/heap/rewriteheap.c | modified | +1 −1 |
| src/backend/access/transam/xlog.c | modified | +3 −27 |
| src/backend/storage/file/buffile.c | modified | +5 −41 |
| src/backend/storage/file/fd.c | modified | +25 −180 |
| src/backend/storage/smgr/md.c | modified | +4 −31 |
| src/include/storage/fd.h | modified | +4 −8 |
Discussion
- Use pread and pwrite instead of lseek + write and read 15 messages · 2016-08-17 → 2016-09-15
- lseek/read/write overhead becomes visible at scale .. 21 messages · 2017-01-24 → 2018-05-25
- pread() and pwrite() 41 messages · 2018-07-12 → 2018-11-07