forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit31966b1
committed
bufmgr: Introduce infrastructure for faster relation extension
The primary bottlenecks for relation extension are:1) The extension lock is held while acquiring a victim buffer for the new page. Acquiring a victim buffer can require writing out the old page contents including possibly needing to flush WAL.2) When extending via ReadBuffer() et al, we write a zero page during the extension, and then later write out the actual page contents. This can nearly double the write rate.3) The existing bulk relation extension infrastructure in hio.c just amortized the cost of acquiring the relation extension lock, but none of the other costs.Unfortunately 1) cannot currently be addressed in a central manner as thecallers to ReadBuffer() need to acquire the extension lock. To address that,this this commit moves the responsibility for acquiring the extension lockinto bufmgr.c functions. That allows to acquire the relation extension lockfor just the required time. This will also allow us to improve relationextension further, without changing callers.The reason we write all-zeroes pages during relation extension is that we hopeto get ENOSPC errors earlier that way (largely works, except for CoWfilesystems). It is easier to handle out-of-space errors gracefully if thepage doesn't yet contain actual tuples. This commit addresses 2), by using therecently introduced smgrzeroextend(), which extends the relation, withoutdirtying the kernel page cache for all the extended pages.To address 3), this commit introduces a function to extend a relation bymultiple blocks at a time.There are three new exposed functions: ExtendBufferedRel() for extending therelation by a single block, ExtendBufferedRelBy() to extend a relation bymultiple blocks at once, and ExtendBufferedRelTo() for extending a relation upto a certain size.To avoid duplicating code between ReadBuffer(P_NEW) and the new functions,ReadBuffer(P_NEW) now implements relation extension withExtendBufferedRel(), using a flag to tell ExtendBufferedRel() that therelation lock is already held.Note that this commit does not yet lead to a meaningful performance orscalability improvement - for that uses of ReadBuffer(P_NEW) will need to beconverted to ExtendBuffered*(), which will be done in subsequent commits.Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>Discussion:https://postgr.es/m/20221029025420.eplyow6k7tgu6he3@awork3.anarazel.de1 parent8eda731 commit31966b1
File tree
9 files changed
+901
-181
lines changed- doc/src/sgml
- src
- backend
- storage/buffer
- utils
- activity
- include
- storage
- tools/pgindent
9 files changed
+901
-181
lines changedLines changed: 31 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7776 | 7776 |
| |
7777 | 7777 |
| |
7778 | 7778 |
| |
| 7779 | + | |
| 7780 | + | |
| 7781 | + | |
| 7782 | + | |
| 7783 | + | |
| 7784 | + | |
| 7785 | + | |
| 7786 | + | |
| 7787 | + | |
| 7788 | + | |
| 7789 | + | |
| 7790 | + | |
| 7791 | + | |
| 7792 | + | |
| 7793 | + | |
| 7794 | + | |
| 7795 | + | |
| 7796 | + | |
| 7797 | + | |
| 7798 | + | |
| 7799 | + | |
| 7800 | + | |
| 7801 | + | |
| 7802 | + | |
| 7803 | + | |
7779 | 7804 |
| |
7780 | 7805 |
| |
7781 |
| - | |
| 7806 | + | |
7782 | 7807 |
| |
7783 |
| - | |
7784 |
| - | |
| 7808 | + | |
7785 | 7809 |
| |
7786 | 7810 |
| |
7787 | 7811 |
| |
7788 | 7812 |
| |
7789 |
| - | |
7790 |
| - | |
| 7813 | + | |
7791 | 7814 |
| |
7792 | 7815 |
| |
7793 | 7816 |
| |
7794 |
| - | |
| 7817 | + | |
7795 | 7818 |
| |
7796 |
| - | |
7797 |
| - | |
7798 |
| - | |
| 7819 | + | |
7799 | 7820 |
| |
7800 | 7821 |
| |
7801 | 7822 |
| |
7802 | 7823 |
| |
7803 |
| - | |
7804 |
| - | |
7805 |
| - | |
| 7824 | + | |
7806 | 7825 |
| |
7807 | 7826 |
| |
7808 | 7827 |
| |
|
0 commit comments
Comments
(0)