forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit53c2a97
committed
Improve performance of subsystems on top of SLRU
More precisely, what we do here is make the SLRU cache sizesconfigurable with new GUCs, so that sites with high concurrency and bigranges of transactions in flight (resp. multixacts/subtransactions) canbenefit from bigger caches. In order for this to work with goodperformance, two additional changes are made:1. the cache is divided in "banks" (to borrow terminology from CPU caches), and algorithms such as eviction buffer search only affect one specific bank. This forestalls the problem that linear searching for a specific buffer across the whole cache takes too long: we only have to search the specific bank, whose size is small. This work is authored by Andrey Borodin.2. Change the locking regime for the SLRU banks, so that each bank uses a separate LWLock. This allows for increased scalability. This work is authored by Dilip Kumar. (A part of this was previously committed asd172b71.)Special care is taken so that the algorithms that can potentiallytraverse more than one bank release one bank's lock before acquiring thenext. This should happen rarely, but particularly clog.c's group commitfeature needed code adjustment to cope with this. I (Álvaro) also addedlots of comments to make sure the design is sound.The new GUCs match the names introduced bybcdfa5f in thepg_stat_slru view.The default values for these parameters are similar to the previoussizes of each SLRU. commit_ts, clog and subtrans accept value 0, whichmeans to adjust by dividing shared_buffers by 512 (so 2MB for every 1GBof shared_buffers), with a cap of 8MB. (A new slru.c functionSimpleLruAutotuneBuffers() was added to support this.) The cap waspreviously 1MB for clog, so for sites with more than 512MB of sharedmemory the total memory used increases, which is likely a good tradeoff.However, other SLRUs (notably multixact ones) retain smaller sizes anddon't support a configured value of 0. These values based onshared_buffers may need to be revisited, but that's an easy change.There was some resistance to adding these new GUCs: it would be betterto adjust to memory pressure automatically somehow, for example bystealing memory from shared_buffers (where the caches can grow andshrink naturally). However, doing that seems to be a much largerproject and one which has made virtually no progress in several years,and because this is such a pain point for so many users, here we takethe pragmatic approach.Author: Andrey Borodin <x4mmm@yandex-team.ru>Author: Dilip Kumar <dilipbalaut@gmail.com>Reviewed-by: Amul Sul, Gilles Darold, Anastasia Lubennikova,Ivan Lazarev, Robert Haas, Thomas Munro, Tomas Vondra,Yura Sokolov, Васильев Дмитрий (Dmitry Vasiliev).Discussion:https://postgr.es/m/2BEC2B3F-9B61-4C1D-9FB5-5FAB0F05EF86@yandex-team.ruDiscussion:https://postgr.es/m/CAFiTN-vzDvNz=ExGXz6gdyjtzGixKSqs0mKHMmaQ8sOSEFZ33A@mail.gmail.com1 parent1c1eec0 commit53c2a97
File tree
26 files changed
+1177
-353
lines changed- doc/src/sgml
- src
- backend
- access/transam
- commands
- storage/lmgr
- utils
- activity
- init
- misc
- include
- access
- commands
- storage
- utils
- test/modules/test_slru
26 files changed
+1177
-353
lines changedLines changed: 139 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2006 | 2006 |
| |
2007 | 2007 |
| |
2008 | 2008 |
| |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
| 2039 | + | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
| 2049 | + | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
2009 | 2148 |
| |
2010 | 2149 |
| |
2011 | 2150 |
| |
|
Lines changed: 8 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4482 | 4482 |
| |
4483 | 4483 |
| |
4484 | 4484 |
| |
4485 |
| - | |
| 4485 | + | |
| 4486 | + | |
4486 | 4487 |
| |
4487 | 4488 |
| |
4488 | 4489 |
| |
4489 | 4490 |
| |
4490 | 4491 |
| |
| 4492 | + | |
| 4493 | + | |
| 4494 | + | |
| 4495 | + | |
| 4496 | + | |
| 4497 | + | |
4491 | 4498 |
| |
4492 | 4499 |
| |
4493 | 4500 |
| |
|
0 commit comments
Comments
(0)