postgresql/src/include/storage
Andres Freund 4d330a61bb Add smgrzeroextend(), FileZero(), FileFallocate()
smgrzeroextend() uses FileFallocate() to efficiently extend files by multiple
blocks. When extending by a small number of blocks, use FileZero() instead, as
using posix_fallocate() for small numbers of blocks is inefficient for some
file systems / operating systems. FileZero() is also used as the fallback for
FileFallocate() on platforms / filesystems that don't support fallocate.

A big advantage of using posix_fallocate() is that it typically won't cause
dirty buffers in the kernel pagecache. So far the most common pattern in our
code is that we smgrextend() a page full of zeroes and put the corresponding
page into shared buffers, from where we later write out the actual contents of
the page. If the kernel, e.g. due to memory pressure or elapsed time, already
wrote back the all-zeroes page, this can lead to doubling the amount of writes
reaching storage.

There are no users of smgrzeroextend() as of this commit. That will follow in
future commits.

Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: John Naylor <john.naylor@enterprisedb.com>
Discussion: https://postgr.es/m/20221029025420.eplyow6k7tgu6he3@awork3.anarazel.de
2023-04-05 10:06:39 -07:00
..
.gitignore When trace_lwlocks is used, identify individual lwlocks by name. 2015-09-11 14:01:39 -04:00
backendid.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
barrier.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
block.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
buf_internals.h Track shared buffer hits in pg_stat_io 2023-03-30 19:24:21 -07:00
buf.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
buffile.h Add BufFileRead variants with short read and EOF detection 2023-01-16 11:01:31 +01:00
bufmgr.h Remove empty function BufmgrCommit(). 2023-03-29 09:13:57 -04:00
bufpage.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
checksum_impl.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
checksum.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
condition_variable.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
copydir.h Constify the arguments of copydir.h functions 2023-01-18 08:55:26 +09:00
dsm_impl.h Avoid type cheats for invalid dsa_handles and dshash_table_handles. 2023-01-25 11:48:38 -05:00
dsm.h Avoid type cheats for invalid dsa_handles and dshash_table_handles. 2023-01-25 11:48:38 -05:00
fd.h Add smgrzeroextend(), FileZero(), FileFallocate() 2023-04-05 10:06:39 -07:00
fileset.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
freespace.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
fsm_internals.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
indexfsm.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
ipc.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
item.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
itemid.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
itemptr.h Consolidate ItemPointer to Datum conversion functions 2023-02-13 09:57:15 +01:00
large_object.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
latch.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
lmgr.h Perform apply of large transactions by parallel workers. 2023-01-09 07:52:45 +05:30
lock.h Use dlist/dclist instead of PROC_QUEUE / SHM_QUEUE for heavyweight locks 2023-01-18 11:41:14 -08:00
lockdefs.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
lwlock.h Track logrep apply workers' last start times to avoid useless waits. 2023-01-22 14:08:46 -05:00
md.h Add smgrzeroextend(), FileZero(), FileFallocate() 2023-04-05 10:06:39 -07:00
meson.build Update copyright for 2023 2023-01-02 15:00:37 -05:00
off.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_sema.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_shmem.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
pmsignal.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
predicate_internals.h Use dlists instead of SHM_QUEUE for predicate locking 2023-01-19 18:55:51 -08:00
predicate.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
proc.h Add new GUC reserved_connections. 2023-01-20 15:39:13 -05:00
procarray.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
proclist_types.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
proclist.h Constify proclist.h 2023-01-19 09:45:34 +01:00
procsignal.h Perform apply of large transactions by parallel workers. 2023-01-09 07:52:45 +05:30
reinit.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
relfilelocator.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
s_lock.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
sharedfileset.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
shm_mq.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
shm_toc.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
shmem.h Remove SHM_QUEUE 2023-01-19 18:55:51 -08:00
sinval.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
sinvaladt.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
smgr.h Add smgrzeroextend(), FileZero(), FileFallocate() 2023-04-05 10:06:39 -07:00
spin.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
standby.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
standbydefs.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
sync.h Update copyright for 2023 2023-01-02 15:00:37 -05:00