forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit941697c
committed
snapshot scalability: Introduce dense array of in-progress xids.
The new array contains the xids for all connected backends / in-usePGPROC entries in a dense manner (in contrast to the PGPROC/PGXACTarrays which can have unused entries interspersed).This improves performance because GetSnapshotData() always needs toscan the xids of all live procarray entries and now there's no need togo through the procArray->pgprocnos indirection anymore.As the set of running top-level xids changes rarely, compared to thenumber of snapshots taken, this substantially increases the likelihoodof most data required for a snapshot being in l2 cache. Inread-mostly workloads scanning the xids[] array will sufficient tobuild a snapshot, as most backends will not have an xid assigned.To keep the xid array dense ProcArrayRemove() needs to move entriesbehind the to-be-removed proc's one further up in the array. Obviouslymoving array entries cannot happen while a backend sets itxid. I.e. locking needs to prevent that array entries are moved whilea backend modifies its xid.To avoid locking ProcArrayLock in GetNewTransactionId() - a fairly hotspot already - ProcArrayAdd() / ProcArrayRemove() now needs to holdXidGenLock in addition to ProcArrayLock. Adding / Removing a procarrayentry is not a very frequent operation, even taking 2PC into account.Due to the above, the dense array entries can only be read or modifiedwhile holding ProcArrayLock and/or XidGenLock. This prevents aconcurrent ProcArrayRemove() from shifting the dense array while it isaccessed concurrently.While the new dense array is very good when needing to look at allxids it is less suitable when accessing a single backend's xid. Inparticular it would be problematic to have to acquire a lock to accessa backend's own xid. Therefore a backend's xid is not just stored inthe dense array, but also in PGPROC. This also allows a backend toonly access the shared xid value when the backend had acquired anxid.The infrastructure added in this commit will be used for the remainingPGXACT fields in subsequent commits. They are kept separate to makereview easier.Author: Andres Freund <andres@anarazel.de>Reviewed-By: Robert Haas <robertmhaas@gmail.com>Reviewed-By: Thomas Munro <thomas.munro@gmail.com>Reviewed-By: David Rowley <dgrowleyml@gmail.com>Discussion:https://postgr.es/m/20200301083601.ews6hz5dduc3w2se@alap3.anarazel.de1 parent2ba5b2d commit941697c
File tree
11 files changed
+327
-154
lines changed- src
- backend
- access
- heap
- transam
- commands
- storage
- ipc
- lmgr
- include/storage
11 files changed
+327
-154
lines changedLines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
14 |
| - | |
| 14 | + | |
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
18 | 18 |
| |
19 |
| - | |
| 19 | + | |
20 | 20 |
| |
21 | 21 |
| |
22 | 22 |
| |
| |||
956 | 956 |
| |
957 | 957 |
| |
958 | 958 |
| |
959 |
| - | |
| 959 | + | |
960 | 960 |
| |
961 | 961 |
| |
962 | 962 |
| |
| |||
1459 | 1459 |
| |
1460 | 1460 |
| |
1461 | 1461 |
| |
1462 |
| - | |
| 1462 | + | |
1463 | 1463 |
| |
1464 | 1464 |
| |
1465 | 1465 |
| |
|
Lines changed: 15 additions & 14 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
251 | 251 |
| |
252 | 252 |
| |
253 | 253 |
| |
254 |
| - | |
255 |
| - | |
256 |
| - | |
257 |
| - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
258 | 258 |
| |
259 | 259 |
| |
260 | 260 |
| |
| |||
278 | 278 |
| |
279 | 279 |
| |
280 | 280 |
| |
281 |
| - | |
282 |
| - | |
283 |
| - | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
284 | 284 |
| |
285 | 285 |
| |
286 |
| - | |
| 286 | + | |
287 | 287 |
| |
288 | 288 |
| |
289 | 289 |
| |
| |||
382 | 382 |
| |
383 | 383 |
| |
384 | 384 |
| |
385 |
| - | |
386 |
| - | |
387 |
| - | |
388 |
| - | |
389 |
| - | |
390 |
| - | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
391 | 392 |
| |
392 | 393 |
| |
393 | 394 |
| |
|
Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
285 | 285 |
| |
286 | 286 |
| |
287 | 287 |
| |
288 |
| - | |
289 |
| - | |
290 |
| - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
291 | 291 |
| |
292 | 292 |
| |
293 | 293 |
| |
294 | 294 |
| |
295 | 295 |
| |
296 |
| - | |
| 296 | + | |
297 | 297 |
| |
298 | 298 |
| |
299 | 299 |
| |
|
Lines changed: 13 additions & 18 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
351 | 351 |
| |
352 | 352 |
| |
353 | 353 |
| |
354 |
| - | |
| 354 | + | |
355 | 355 |
| |
356 | 356 |
| |
357 | 357 |
| |
| |||
463 | 463 |
| |
464 | 464 |
| |
465 | 465 |
| |
466 |
| - | |
| 466 | + | |
467 | 467 |
| |
468 | 468 |
| |
469 | 469 |
| |
| |||
768 | 768 |
| |
769 | 769 |
| |
770 | 770 |
| |
771 |
| - | |
772 | 771 |
| |
773 | 772 |
| |
774 | 773 |
| |
| |||
783 | 782 |
| |
784 | 783 |
| |
785 | 784 |
| |
786 |
| - | |
| 785 | + | |
787 | 786 |
| |
788 | 787 |
| |
789 | 788 |
| |
| |||
829 | 828 |
| |
830 | 829 |
| |
831 | 830 |
| |
832 |
| - | |
833 | 831 |
| |
834 |
| - | |
| 832 | + | |
835 | 833 |
| |
836 | 834 |
| |
837 | 835 |
| |
| |||
987 | 985 |
| |
988 | 986 |
| |
989 | 987 |
| |
990 |
| - | |
991 |
| - | |
| 988 | + | |
992 | 989 |
| |
993 | 990 |
| |
994 | 991 |
| |
| |||
1140 | 1137 |
| |
1141 | 1138 |
| |
1142 | 1139 |
| |
1143 |
| - | |
| 1140 | + | |
1144 | 1141 |
| |
1145 | 1142 |
| |
1146 | 1143 |
| |
1147 |
| - | |
1148 |
| - | |
1149 |
| - | |
1150 |
| - | |
1151 |
| - | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
1152 | 1149 |
| |
1153 | 1150 |
| |
1154 | 1151 |
| |
| |||
1404 | 1401 |
| |
1405 | 1402 |
| |
1406 | 1403 |
| |
1407 |
| - | |
1408 | 1404 |
| |
1409 | 1405 |
| |
1410 | 1406 |
| |
| |||
1423 | 1419 |
| |
1424 | 1420 |
| |
1425 | 1421 |
| |
1426 |
| - | |
1427 |
| - | |
| 1422 | + | |
1428 | 1423 |
| |
1429 | 1424 |
| |
1430 | 1425 |
| |
| |||
1726 | 1721 |
| |
1727 | 1722 |
| |
1728 | 1723 |
| |
1729 |
| - | |
| 1724 | + | |
1730 | 1725 |
| |
1731 | 1726 |
| |
1732 | 1727 |
| |
|
Lines changed: 13 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
38 | 38 |
| |
39 | 39 |
| |
40 | 40 |
| |
41 |
| - | |
| 41 | + | |
| 42 | + | |
42 | 43 |
| |
43 | 44 |
| |
44 | 45 |
| |
| |||
65 | 66 |
| |
66 | 67 |
| |
67 | 68 |
| |
68 |
| - | |
| 69 | + | |
| 70 | + | |
69 | 71 |
| |
70 | 72 |
| |
71 | 73 |
| |
| |||
190 | 192 |
| |
191 | 193 |
| |
192 | 194 |
| |
193 |
| - | |
194 |
| - | |
195 |
| - | |
196 |
| - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
197 | 199 |
| |
198 | 200 |
| |
199 | 201 |
| |
| |||
219 | 221 |
| |
220 | 222 |
| |
221 | 223 |
| |
222 |
| - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
223 | 229 |
| |
224 | 230 |
| |
225 | 231 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1724 | 1724 |
| |
1725 | 1725 |
| |
1726 | 1726 |
| |
1727 |
| - | |
| 1727 | + | |
1728 | 1728 |
| |
1729 | 1729 |
| |
1730 | 1730 |
| |
|
0 commit comments
Comments
(0)