forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit64b1fb5
committed
Optimize pg_atomic_exchange_u32 and pg_atomic_exchange_u64.
Presently, all platforms implement atomic exchanges by performingan atomic compare-and-swap in a loop until it succeeds. This canbe especially expensive when there is contention on the atomicvariable. This commit optimizes atomic exchanges on many platformsby using compiler intrinsics, which should compile into somethingmuch less expensive than a compare-and-swap loop. Since theseintrinsics have been available for some time, the inline assemblyimplementations are omitted.Suggested-by: Andres FreundReviewed-by: Andres FreundDiscussion:https://postgr.es/m/20231129212905.GA1258737%40nathanxps131 parent0d1adae commit64b1fb5
File tree
3 files changed
+66
-0
lines changed- src/include/port/atomics
3 files changed
+66
-0
lines changedLines changed: 34 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
176 | 176 |
| |
177 | 177 |
| |
178 | 178 |
| |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
179 | 196 |
| |
180 | 197 |
| |
181 | 198 |
| |
| |||
243 | 260 |
| |
244 | 261 |
| |
245 | 262 |
| |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
246 | 280 |
| |
247 | 281 |
| |
248 | 282 |
| |
|
Lines changed: 18 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
58 | 58 |
| |
59 | 59 |
| |
60 | 60 |
| |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
61 | 68 |
| |
62 | 69 |
| |
63 | 70 |
| |
| |||
88 | 95 |
| |
89 | 96 |
| |
90 | 97 |
| |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
91 | 108 |
| |
92 | 109 |
| |
93 | 110 |
| |
| |||
96 | 113 |
| |
97 | 114 |
| |
98 | 115 |
| |
| 116 | + | |
99 | 117 |
| |
100 | 118 |
| |
101 | 119 |
|
Lines changed: 14 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
87 | 87 |
| |
88 | 88 |
| |
89 | 89 |
| |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
90 | 97 |
| |
91 | 98 |
| |
92 | 99 |
| |
| |||
101 | 108 |
| |
102 | 109 |
| |
103 | 110 |
| |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
104 | 118 |
| |
105 | 119 |
| |
106 | 120 |
|
0 commit comments
Comments
(0)