- Notifications
You must be signed in to change notification settings - Fork5
Commit5d7962c
committed
Change locking regimen around buffer replacement.
Previously, we used an lwlock that was held from the time we beganseeking a candidate buffer until the time when we found and pinnedone, which is disastrous for concurrency. Instead, use a spinlockwhich is held just long enough to pop the freelist or advance theclock sweep hand, and then released. If we need to advance the clocksweep further, we reacquire the spinlock once per buffer.This represents a significant increase in atomic operations aroundbuffer eviction, but it still wins on many workloads. On others, itmay result in no gain, or even cause a regression, unless the numberof buffer mapping locks is also increased. However, that seems likematerial for a separate commit. We may also need to consider othermethods of mitigating contention on this spinlock, such as splittingit into multiple locks or jumping the clock sweep hand more than onebuffer at a time, but those, too, seem like separate improvements.Patch by me, inspired by a much larger patch from Amit Kapila.Reviewed by Andres Freund.1 parent1dcfb8d commit5d7962c
File tree
5 files changed
+61
-60
lines changed- src
- backend/storage/buffer
- include/storage
5 files changed
+61
-60
lines changedLines changed: 19 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
125 | 125 |
| |
126 | 126 |
| |
127 | 127 |
| |
128 |
| - | |
| 128 | + | |
129 | 129 |
| |
130 |
| - | |
131 |
| - | |
132 |
| - | |
133 |
| - | |
134 |
| - | |
135 |
| - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
136 | 134 |
| |
137 | 135 |
| |
138 | 136 |
| |
| |||
165 | 163 |
| |
166 | 164 |
| |
167 | 165 |
| |
168 |
| - | |
| 166 | + | |
169 | 167 |
| |
170 | 168 |
| |
171 | 169 |
| |
| |||
178 | 176 |
| |
179 | 177 |
| |
180 | 178 |
| |
181 |
| - | |
| 179 | + | |
182 | 180 |
| |
183 | 181 |
| |
184 | 182 |
| |
185 |
| - | |
| 183 | + | |
186 | 184 |
| |
187 |
| - | |
188 |
| - | |
189 |
| - | |
190 |
| - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
191 | 189 |
| |
192 |
| - | |
193 |
| - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
194 | 193 |
| |
195 | 194 |
| |
196 |
| - | |
197 |
| - | |
| 195 | + | |
| 196 | + | |
198 | 197 |
| |
199 |
| - | |
| 198 | + | |
200 | 199 |
| |
201 | 200 |
| |
202 | 201 |
| |
| |||
259 | 258 |
| |
260 | 259 |
| |
261 | 260 |
| |
262 |
| - | |
| 261 | + | |
263 | 262 |
| |
264 | 263 |
| |
265 | 264 |
| |
|
Lines changed: 2 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
889 | 889 |
| |
890 | 890 |
| |
891 | 891 |
| |
892 |
| - | |
893 |
| - | |
894 | 892 |
| |
895 | 893 |
| |
896 |
| - | |
897 |
| - | |
898 |
| - | |
| 894 | + | |
899 | 895 |
| |
900 |
| - | |
| 896 | + | |
901 | 897 |
| |
902 | 898 |
| |
903 | 899 |
| |
| |||
907 | 903 |
| |
908 | 904 |
| |
909 | 905 |
| |
910 |
| - | |
911 |
| - | |
912 |
| - | |
913 |
| - | |
914 | 906 |
| |
915 | 907 |
| |
916 | 908 |
| |
|
Lines changed: 37 additions & 26 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
24 | 24 |
| |
25 | 25 |
| |
26 | 26 |
| |
| 27 | + | |
| 28 | + | |
| 29 | + | |
27 | 30 |
| |
28 | 31 |
| |
29 | 32 |
| |
| |||
101 | 104 |
| |
102 | 105 |
| |
103 | 106 |
| |
104 |
| - | |
105 |
| - | |
106 |
| - | |
107 |
| - | |
108 |
| - | |
109 |
| - | |
| 107 | + | |
110 | 108 |
| |
111 | 109 |
| |
112 |
| - | |
| 110 | + | |
113 | 111 |
| |
114 | 112 |
| |
115 | 113 |
| |
116 | 114 |
| |
117 | 115 |
| |
118 | 116 |
| |
119 | 117 |
| |
120 |
| - | |
| 118 | + | |
121 | 119 |
| |
122 | 120 |
| |
123 | 121 |
| |
124 | 122 |
| |
125 | 123 |
| |
126 |
| - | |
127 |
| - | |
128 | 124 |
| |
129 |
| - | |
130 | 125 |
| |
131 | 126 |
| |
132 | 127 |
| |
133 |
| - | |
134 |
| - | |
| 128 | + | |
135 | 129 |
| |
136 | 130 |
| |
137 | 131 |
| |
| |||
142 | 136 |
| |
143 | 137 |
| |
144 | 138 |
| |
145 |
| - | |
146 |
| - | |
147 |
| - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
148 | 142 |
| |
149 | 143 |
| |
150 | 144 |
| |
151 | 145 |
| |
152 | 146 |
| |
153 |
| - | |
| 147 | + | |
154 | 148 |
| |
155 |
| - | |
| 149 | + | |
156 | 150 |
| |
157 | 151 |
| |
158 | 152 |
| |
159 | 153 |
| |
160 |
| - | |
| 154 | + | |
161 | 155 |
| |
162 | 156 |
| |
163 | 157 |
| |
| |||
170 | 164 |
| |
171 | 165 |
| |
172 | 166 |
| |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
173 | 173 |
| |
174 | 174 |
| |
175 | 175 |
| |
| |||
185 | 185 |
| |
186 | 186 |
| |
187 | 187 |
| |
| 188 | + | |
| 189 | + | |
| 190 | + | |
188 | 191 |
| |
189 | 192 |
| |
190 | 193 |
| |
| |||
199 | 202 |
| |
200 | 203 |
| |
201 | 204 |
| |
| 205 | + | |
| 206 | + | |
| 207 | + | |
202 | 208 |
| |
203 | 209 |
| |
204 | 210 |
| |
| |||
232 | 238 |
| |
233 | 239 |
| |
234 | 240 |
| |
| 241 | + | |
| 242 | + | |
| 243 | + | |
235 | 244 |
| |
236 | 245 |
| |
237 | 246 |
| |
| |||
241 | 250 |
| |
242 | 251 |
| |
243 | 252 |
| |
244 |
| - | |
| 253 | + | |
245 | 254 |
| |
246 | 255 |
| |
247 | 256 |
| |
| |||
255 | 264 |
| |
256 | 265 |
| |
257 | 266 |
| |
258 |
| - | |
| 267 | + | |
259 | 268 |
| |
260 | 269 |
| |
261 | 270 |
| |
| |||
274 | 283 |
| |
275 | 284 |
| |
276 | 285 |
| |
277 |
| - | |
| 286 | + | |
278 | 287 |
| |
279 | 288 |
| |
280 | 289 |
| |
| |||
283 | 292 |
| |
284 | 293 |
| |
285 | 294 |
| |
286 |
| - | |
| 295 | + | |
287 | 296 |
| |
288 | 297 |
| |
289 | 298 |
| |
| |||
299 | 308 |
| |
300 | 309 |
| |
301 | 310 |
| |
302 |
| - | |
| 311 | + | |
303 | 312 |
| |
304 | 313 |
| |
305 | 314 |
| |
306 |
| - | |
| 315 | + | |
307 | 316 |
| |
308 |
| - | |
| 317 | + | |
309 | 318 |
| |
310 | 319 |
| |
311 | 320 |
| |
| |||
370 | 379 |
| |
371 | 380 |
| |
372 | 381 |
| |
| 382 | + | |
| 383 | + | |
373 | 384 |
| |
374 | 385 |
| |
375 | 386 |
| |
|
Lines changed: 2 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
115 | 115 |
| |
116 | 116 |
| |
117 | 117 |
| |
118 |
| - | |
| 118 | + | |
119 | 119 |
| |
120 | 120 |
| |
121 | 121 |
| |
| |||
185 | 185 |
| |
186 | 186 |
| |
187 | 187 |
| |
188 |
| - | |
189 |
| - | |
| 188 | + | |
190 | 189 |
| |
191 | 190 |
| |
192 | 191 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
89 | 89 |
| |
90 | 90 |
| |
91 | 91 |
| |
92 |
| - | |
| 92 | + | |
93 | 93 |
| |
94 | 94 |
| |
95 | 95 |
| |
|
0 commit comments
Comments
(0)