Re: SLRU optimization - configurable buffer pool and partitioning the SLRU lock
Dilip Kumar <dilipbalaut@gmail.com>
From: Dilip Kumar <dilipbalaut@gmail.com>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2023-10-30T06:20:40Z
Lists: pgsql-hackers
Attachments
- v3-0005-Merge-bank-locks-array-with-buffer-locks-array.patch (application/octet-stream) patch v3-0005
- v3-0002-Divide-SLRU-buffers-into-banks.patch (application/octet-stream) patch v3-0002
- v3-0004-Introduce-bank-wise-LRU-counter.patch (application/octet-stream) patch v3-0004
- v3-0001-Make-all-SLRU-buffer-sizes-configurable.patch (application/octet-stream) patch v3-0001
- v3-0003-Bank-wise-slru-locks.patch (application/octet-stream) patch v3-0003
On Wed, Oct 25, 2023 at 10:34 AM Dilip Kumar <dilipbalaut@gmail.com> wrote: > > On Tue, Oct 24, 2023 at 9:34 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote: > Overall I agree with your comments, actually, I haven't put that much > thought into the GUC part and how it scales the SLRU buffers w.r.t. > this single configurable parameter. Yeah, so I think it is better > that we take the older patch version as our base patch where we have > separate GUC per SLRU. > > > I'm inclined to use Borodin's patch last posted here [2] instead of your > > proposed 0001. > > [2] https://postgr.es/m/93236D36-B91C-4DFA-AF03-99C083840378@yandex-team.ru > > I will rebase my patches on top of this. I have taken 0001 and 0002 from [1], done some bug fixes in 0001, and changed the logic of SlruAdjustNSlots() in 0002, such that now it starts with the next power of 2 value of the configured slots and keeps doubling the number of banks until we reach the number of banks to the max SLRU_MAX_BANKS(128) and bank size is bigger than SLRU_MIN_BANK_SIZE (8). By doing so, we will ensure we don't have too many banks, but also that we don't have very large banks. There was also a patch 0003 in this thread but I haven't taken this as this is another optimization of merging some structure members and I will analyze the performance characteristic of this and try to add it on top of the complete patch series. Patch details: 0001 - GUC parameter for each SLRU 0002 - Divide the SLRU pool into banks (The above 2 are taken from [1] with some modification and rebasing by me) 0003 - Implement bank-wise SLRU lock as described in the first email of this thread 0004 - Implement bank-wise LRU counter as described in the first email of this thread 0005 - Some other optimization suggested offlist by Alvaro, i.e. merging buffer locks and bank locks in the same array so that the bank-wise LRU counter does not fetch the next cache line in a hot function SlruRecentlyUsed() Note: I think 0003,0004 and 0005 can be merged together but kept separate so that we can review them independently and see how useful each of them is. [1] https://postgr.es/m/93236D36-B91C-4DFA-AF03-99C083840378@yandex-team.ru -- Regards, Dilip Kumar EnterpriseDB: http://www.enterprisedb.com
Commits
-
Fix zeroing of pg_serial page without SLRU bank lock
- be2f07310063 17.0 landed
-
Fix misspelled assertions
- 0d3a71d0c8a7 17.0 landed
-
GUC table: Add description to computed variables
- 30b8d6e4ce11 17.0 landed
-
Improve performance of subsystems on top of SLRU
- 53c2a97a9266 17.0 landed
-
Rename SLRU elements in view pg_stat_slru
- bcdfa5f2e2f2 17.0 landed
-
Use atomic access for SlruShared->latest_page_number
- d172b717c6f4 17.0 landed
-
Split use of SerialSLRULock, creating SerialControlLock
- 7b745d85b80d 17.0 landed
-
Index SLRUs by 64-bit integers rather than by 32-bit integers
- 4ed8f0913bfd 17.0 cited
-
Add a macro templatized hashtable.
- b30d3ea824c5 10.0 cited