forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit159f8c6
committed
From: Dan McGuirk <mcguirk@indirect.com>
Reply-To: hackers@hub.org, Dan McGuirk <mcguirk@indirect.com>To: hackers@hub.orgSubject: [HACKERS] tmin writeback optimizationI was doing some profiling of the backend, and noticed that during a certainbenchmark I was running somewhere between 30% and 75% of the backend's CPUtime was being spent in calls to TransactionIdDidCommit() fromHeapTupleSatisfiesNow() or HeapTupleSatisfiesItself() to determine thatchanged rows' transactions had in fact been committed even though the rows'tmin values had not yet been set.When a query looks at a given row, it needs to figure out whether thetransaction that changed the row has been committed and hence it should payattention to the row, or whether on the other hand the transaction is stillin progress or has been aborted and hence the row should be ignored. Ifa tmin value is set, it is known definitively that the row's transactionhas been committed. However, if tmin is not set, the transactionreferred to in xmin must be looked up in pg_log, and this is what thebackend was spending a lot of time doing during my benchmark.So, implementing a method suggested by Vadim, I created the followingpatch that, the first time a query finds a committed row whose tmin valueis not set, sets it, and marks the buffer where the row is stored asdirty. (It works for tmax, too.) This doesn't result in the boost inreal time performance I was hoping for, however it does decrease backendCPU usage by up to two-thirds in certain situations, so it could berather beneficial in high-concurrency settings.1 parentd98f72e commit159f8c6
File tree
8 files changed
+110
-34
lines changed- src
- backend
- access
- common
- heap
- storage/buffer
- utils/time
- include
- access
- storage
8 files changed
+110
-34
lines changedLines changed: 26 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 |
| - | |
| 10 | + | |
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
| |||
21 | 21 |
| |
22 | 22 |
| |
23 | 23 |
| |
| 24 | + | |
24 | 25 |
| |
25 | 26 |
| |
26 | 27 |
| |
| |||
89 | 90 |
| |
90 | 91 |
| |
91 | 92 |
| |
| 93 | + | |
92 | 94 |
| |
93 | 95 |
| |
94 | 96 |
| |
95 | 97 |
| |
96 | 98 |
| |
97 |
| - | |
| 99 | + | |
98 | 100 |
| |
99 |
| - | |
| 101 | + | |
| 102 | + | |
100 | 103 |
| |
101 | 104 |
| |
102 | 105 |
| |
| |||
107 | 110 |
| |
108 | 111 |
| |
109 | 112 |
| |
110 |
| - | |
111 |
| - | |
112 |
| - | |
113 |
| - | |
114 |
| - | |
115 |
| - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
116 | 133 |
| |
117 | 134 |
| |
118 | 135 |
| |
|
Lines changed: 5 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 |
| - | |
| 10 | + | |
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
| |||
388 | 388 |
| |
389 | 389 |
| |
390 | 390 |
| |
391 |
| - | |
| 391 | + | |
392 | 392 |
| |
393 | 393 |
| |
394 | 394 |
| |
| |||
1009 | 1009 |
| |
1010 | 1010 |
| |
1011 | 1011 |
| |
1012 |
| - | |
| 1012 | + | |
1013 | 1013 |
| |
1014 | 1014 |
| |
1015 | 1015 |
| |
| |||
1154 | 1154 |
| |
1155 | 1155 |
| |
1156 | 1156 |
| |
1157 |
| - | |
| 1157 | + | |
1158 | 1158 |
| |
1159 | 1159 |
| |
1160 | 1160 |
| |
| |||
1282 | 1282 |
| |
1283 | 1283 |
| |
1284 | 1284 |
| |
| 1285 | + | |
1285 | 1286 |
| |
1286 | 1287 |
| |
1287 | 1288 |
| |
|
Lines changed: 4 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 |
| - | |
| 10 | + | |
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
| |||
64 | 64 |
| |
65 | 65 |
| |
66 | 66 |
| |
| 67 | + | |
| 68 | + | |
67 | 69 |
| |
68 | 70 |
| |
69 | 71 |
| |
| |||
236 | 238 |
| |
237 | 239 |
| |
238 | 240 |
| |
| 241 | + | |
239 | 242 |
| |
240 | 243 |
| |
241 | 244 |
| |
|
Lines changed: 15 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 |
| - | |
| 10 | + | |
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
| |||
848 | 848 |
| |
849 | 849 |
| |
850 | 850 |
| |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
851 | 855 |
| |
852 | 856 |
| |
853 | 857 |
| |
| |||
1083 | 1087 |
| |
1084 | 1088 |
| |
1085 | 1089 |
| |
| 1090 | + | |
1086 | 1091 |
| |
1087 | 1092 |
| |
1088 | 1093 |
| |
| |||
1498 | 1503 |
| |
1499 | 1504 |
| |
1500 | 1505 |
| |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
1501 | 1510 |
| |
1502 | 1511 |
| |
1503 | 1512 |
| |
| |||
1734 | 1743 |
| |
1735 | 1744 |
| |
1736 | 1745 |
| |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + |
Lines changed: 52 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 |
| - | |
| 10 | + | |
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
| |||
478 | 478 |
| |
479 | 479 |
| |
480 | 480 |
| |
| 481 | + | |
| 482 | + | |
481 | 483 |
| |
482 | 484 |
| |
483 | 485 |
| |
484 | 486 |
| |
485 | 487 |
| |
486 | 488 |
| |
487 | 489 |
| |
488 |
| - | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
489 | 493 |
| |
490 | 494 |
| |
491 |
| - | |
492 |
| - | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
493 | 499 |
| |
494 | 500 |
| |
495 | 501 |
| |
| |||
508 | 514 |
| |
509 | 515 |
| |
510 | 516 |
| |
| 517 | + | |
| 518 | + | |
511 | 519 |
| |
512 | 520 |
| |
513 | 521 |
| |
| |||
522 | 530 |
| |
523 | 531 |
| |
524 | 532 |
| |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
525 | 537 |
| |
526 |
| - | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
527 | 542 |
| |
528 | 543 |
| |
529 | 544 |
| |
530 | 545 |
| |
531 | 546 |
| |
| 547 | + | |
| 548 | + | |
| 549 | + | |
532 | 550 |
| |
533 | 551 |
| |
534 | 552 |
| |
535 | 553 |
| |
536 | 554 |
| |
537 | 555 |
| |
538 | 556 |
| |
539 |
| - | |
540 |
| - | |
541 |
| - | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
542 | 563 |
| |
543 |
| - | |
544 |
| - | |
545 |
| - | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
546 | 570 |
| |
547 | 571 |
| |
548 | 572 |
| |
| |||
605 | 629 |
| |
606 | 630 |
| |
607 | 631 |
| |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
608 | 639 |
| |
609 | 640 |
| |
610 | 641 |
| |
| |||
615 | 646 |
| |
616 | 647 |
| |
617 | 648 |
| |
618 |
| - | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
619 | 654 |
| |
620 |
| - | |
| 655 | + | |
621 | 656 |
| |
622 |
| - | |
623 |
| - | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
624 | 661 |
| |
625 | 662 |
| |
626 | 663 |
| |
|
Lines changed: 4 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6 | 6 |
| |
7 | 7 |
| |
8 | 8 |
| |
9 |
| - | |
| 9 | + | |
10 | 10 |
| |
11 | 11 |
| |
12 | 12 |
| |
| |||
26 | 26 |
| |
27 | 27 |
| |
28 | 28 |
| |
29 |
| - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
30 | 32 |
| |
31 | 33 |
| |
32 | 34 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6 | 6 |
| |
7 | 7 |
| |
8 | 8 |
| |
9 |
| - | |
| 9 | + | |
10 | 10 |
| |
11 | 11 |
| |
12 | 12 |
| |
| |||
216 | 216 |
| |
217 | 217 |
| |
218 | 218 |
| |
| 219 | + | |
219 | 220 |
| |
220 | 221 |
| |
221 | 222 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6 | 6 |
| |
7 | 7 |
| |
8 | 8 |
| |
9 |
| - | |
| 9 | + | |
10 | 10 |
| |
11 | 11 |
| |
12 | 12 |
| |
| |||
114 | 114 |
| |
115 | 115 |
| |
116 | 116 |
| |
| 117 | + | |
117 | 118 |
| |
118 | 119 |
| |
119 | 120 |
|
0 commit comments
Comments
(0)