forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit225a22b
committed
Improve efficiency of wait event reporting, remove proc.h dependency.
pgstat_report_wait_start() and pgstat_report_wait_end() required twoconditional branches so far. One to check if MyProc is NULL, the other tocheck if pgstat_track_activities is set. As wait events are used aroundcomparatively lightweight operations, and are inlined (reducing branchpredictor effectiveness), that's not great.The dependency on MyProc has a second disadvantage: Low-level subsystems, likestorage/file/fd.c, report wait events, but architecturally it is preferablefor them to not depend on inter-process subsystems like proc.h (definingPGPROC). After this change including pgstat.h (nor obviously itssub-components like backend_status.h, wait_event.h, ...) does not pull in IPCrelated headers anymore.These goals, efficiency and abstraction, are achieved by havingpgstat_report_wait_start/end() not interact with MyProc, but instead a newmy_wait_event_info variable. At backend startup it points to a local variable,removing the need to check for MyProc being NULL. During processinitialization my_wait_event_info is redirected to MyProc->wait_event_info. Atshutdown this is reversed. Because wait event reporting now does not need toknow about where the wait event is stored, it does not need to know aboutPGPROC anymore.The removal of the branch for checking pgstat_track_activities is simpler:Don't check anymore. The cost due to the branch are often higher than thestore - and even if not, pgstat_track_activities is rarely disabled.The main motivator to commit this work now is that removing the (indirect)pgproc.h include from pgstat.h simplifies a patch to move statistics reportingto shared memory (which still has a chance to get into 14).Author: Andres Freund <andres@anarazel.de>Discussion:https://postgr.es/m/20210402194458.2vu324hkk2djq6ce@alap3.anarazel.de1 parente102504 commit225a22b
File tree
3 files changed
+69
-38
lines changed- src
- backend
- storage/lmgr
- utils/activity
- include/utils
3 files changed
+69
-38
lines changedLines changed: 16 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
448 | 448 |
| |
449 | 449 |
| |
450 | 450 |
| |
| 451 | + | |
| 452 | + | |
| 453 | + | |
451 | 454 |
| |
452 | 455 |
| |
453 | 456 |
| |
| |||
601 | 604 |
| |
602 | 605 |
| |
603 | 606 |
| |
| 607 | + | |
| 608 | + | |
| 609 | + | |
604 | 610 |
| |
605 | 611 |
| |
606 | 612 |
| |
| |||
884 | 890 |
| |
885 | 891 |
| |
886 | 892 |
| |
887 |
| - | |
888 |
| - | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
889 | 898 |
| |
890 | 899 |
| |
| 900 | + | |
| 901 | + | |
891 | 902 |
| |
892 | 903 |
| |
893 | 904 |
| |
| |||
952 | 963 |
| |
953 | 964 |
| |
954 | 965 |
| |
955 |
| - | |
956 |
| - | |
957 |
| - | |
958 |
| - | |
959 |
| - | |
960 |
| - | |
| 966 | + | |
961 | 967 |
| |
| 968 | + | |
| 969 | + | |
962 | 970 |
| |
963 | 971 |
| |
964 | 972 |
| |
|
Lines changed: 41 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
10 | 21 |
| |
11 | 22 |
| |
12 | 23 |
| |
| |||
23 | 34 |
| |
24 | 35 |
| |
25 | 36 |
| |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
26 | 67 |
| |
27 | 68 |
| |
28 | 69 |
| |
|
Lines changed: 12 additions & 30 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
14 |
| - | |
15 |
| - | |
16 |
| - | |
17 | 14 |
| |
18 | 15 |
| |
19 | 16 |
| |
| |||
234 | 231 |
| |
235 | 232 |
| |
236 | 233 |
| |
| 234 | + | |
| 235 | + | |
237 | 236 |
| |
238 |
| - | |
239 |
| - | |
240 |
| - | |
241 |
| - | |
242 |
| - | |
243 |
| - | |
| 237 | + | |
244 | 238 |
| |
245 | 239 |
| |
246 | 240 |
| |
| |||
254 | 248 |
| |
255 | 249 |
| |
256 | 250 |
| |
257 |
| - | |
258 |
| - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
259 | 257 |
| |
260 | 258 |
| |
261 | 259 |
| |
262 | 260 |
| |
263 | 261 |
| |
264 |
| - | |
265 |
| - | |
266 |
| - | |
267 |
| - | |
268 |
| - | |
269 | 262 |
| |
270 | 263 |
| |
271 | 264 |
| |
272 | 265 |
| |
273 |
| - | |
| 266 | + | |
274 | 267 |
| |
275 | 268 |
| |
276 | 269 |
| |
277 | 270 |
| |
278 | 271 |
| |
279 | 272 |
| |
280 |
| - | |
281 |
| - | |
282 |
| - | |
283 | 273 |
| |
284 | 274 |
| |
285 | 275 |
| |
286 | 276 |
| |
287 | 277 |
| |
288 |
| - | |
289 |
| - | |
290 |
| - | |
291 |
| - | |
292 |
| - | |
293 |
| - | |
294 |
| - | |
295 |
| - | |
296 |
| - | |
297 |
| - | |
| 278 | + | |
| 279 | + | |
298 | 280 |
| |
299 | 281 |
| |
300 | 282 |
| |
|
0 commit comments
Comments
(0)