postgresql/src/include/storage
Tom Lane 06998eab16 Improve heuristics for compressing the KnownAssignedXids array.
Previously, we'd compress only when the active range of array entries
reached Max(4 * PROCARRAY_MAXPROCS, 2 * pArray->numKnownAssignedXids).
If max_connections is large, the first term could result in not
compressing for a long time, resulting in much wastage of cycles in
hot-standby backends scanning the array to take snapshots.  Get rid
of that term, and just bound it to 2 * pArray->numKnownAssignedXids.

That however creates the opposite risk, that we might spend too much
effort compressing.  Hence, consider compressing only once every 128
commit records.  (This frequency was chosen by benchmarking.  While
we only tried one benchmark scenario, the results seem stable over
a fairly wide range of frequencies.)

Also, force compression when processing RecoveryInfo WAL records
(which should be infrequent); the old code could perform compression
then, but would do so only after the same array-range check as for
the transaction-commit path.

Also, opportunistically run compression if the startup process is about
to wait for WAL, though not oftener than once a second.  This should
prevent cases where we waste lots of time by leaving the array
not-compressed for long intervals due to low WAL traffic.

Lastly, add a simple check to keep us from uselessly compressing
when the array storage is already compact.

Back-patch, as the performance problem is worse in pre-v14 branches
than in HEAD.

Simon Riggs and Michail Nikolaev, with help from Tom Lane and
Andres Freund.

Discussion: https://postgr.es/m/CALdSSPgahNUD_=pB_j=1zSnDBaiOtqVfzo8Ejt5J_k7qZiU1Tw@mail.gmail.com
2022-11-29 15:43:17 -05: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 2021 2021-01-02 13:06:25 -05:00
barrier.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
block.h Fix bogus casting in BlockIdGetBlockNumber(). 2022-03-03 19:03:35 -05:00
buf.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
buf_internals.h Improve comment for struct BufferDesc. 2021-03-11 16:38:45 +13:00
buffile.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
bufmgr.h Provide ReadRecentBuffer() to re-pin buffers by ID. 2021-04-08 17:50:25 +12:00
bufpage.h Truncate line pointer array during VACUUM. 2021-04-07 08:47:15 -07:00
checksum.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
checksum_impl.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
condition_variable.h Replace buffer I/O locks with condition variables. 2021-03-11 10:36:17 +13:00
copydir.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
dsm.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
dsm_impl.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
fd.h Initial pgindent and pgperltidy run for v14. 2021-05-12 13:14:10 -04:00
freespace.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
fsm_internals.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
indexfsm.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
ipc.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
item.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
itemid.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
itemptr.h Add TID Range Scans to support efficient scanning ranges of TIDs 2021-02-27 22:59:36 +13:00
large_object.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
latch.h Add support for asynchronous execution. 2021-03-31 18:45:00 +09:00
lmgr.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
lock.h Fix CREATE INDEX CONCURRENTLY for the newest prepared transactions. 2021-10-23 18:36:42 -07:00
lockdefs.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
lwlock.h Fix lock assertions in dshash.c. 2022-07-11 15:47:12 +12:00
md.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
off.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_sema.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_shmem.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
pmsignal.h Make archiver process an auxiliary process. 2021-03-15 13:13:14 +09:00
predicate.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
predicate_internals.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
proc.h Repurpose PROC_COPYABLE_FLAGS as PROC_XMIN_FLAGS 2022-05-19 16:20:32 +02:00
procarray.h Improve heuristics for compressing the KnownAssignedXids array. 2022-11-29 15:43:17 -05:00
proclist.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
proclist_types.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
procsignal.h Add function to log the memory contexts of specified backend process. 2021-04-06 13:44:15 +09:00
reinit.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
relfilenode.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
s_lock.h Allow use of __sync_lock_test_and_set for spinlocks on any machine. 2022-11-02 17:37:26 -04:00
sharedfileset.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
shm_mq.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
shm_toc.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
shmem.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
sinval.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
sinvaladt.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
smgr.h Optimize DropRelFileNodeBuffers() for recovery. 2021-01-12 07:45:40 +05:30
spin.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
standby.h Use full 64-bit XIDs in deleted nbtree pages. 2021-02-24 18:41:34 -08:00
standbydefs.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
sync.h Update copyright for 2021 2021-01-02 13:06:25 -05:00