forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit1d63f7d
committed
Use clock_gettime(), if available, in instr_time measurements.
The advantage of clock_gettime() is that the API allows the result tobe precise to nanoseconds, not just microseconds as in gettimeofday().Now that it's routinely possible to do tens of plan node executionsin 1us, we really need more precision than gettimeofday() can offerfor EXPLAIN ANALYZE to accumulate statistics with.Some research shows that clock_gettime() is available on pretty nearlyevery modern Unix-ish platform, and as far as I have been able to test,it has about the same execution time as gettimeofday(), so there's noloss in switching over. (By the same token, this doesn't do anythingto fix the fact that we really wish clock readings were faster. Butthere's enough win here to justify changing anyway.)A small side benefit is that on most platforms, we can use CLOCK_MONOTONICinstead of CLOCK_REALTIME and thereby render EXPLAIN impervious toconcurrent resets of the system clock. (This means that code must notassume that the contents of struct instr_time have any well-definedinterpretation as timestamps, but really that was true before.)Some platforms offer nonstandard clock IDs that might be of interest.This patch knows we should use CLOCK_MONOTONIC_RAW on macOS, because itprovides more precision and is faster to read than their CLOCK_MONOTONIC.If there turn out to be many more cases where we need special rules, itmight be appropriate to handle the selection of clock ID in configure,but for the moment that doesn't seem worth the trouble.Discussion:https://postgr.es/m/31856.1400021891@sss.pgh.pa.us1 parent67a8753 commit1d63f7d
File tree
5 files changed
+163
-6
lines changed- src/include
- portability
5 files changed
+163
-6
lines changedLines changed: 57 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
9055 | 9055 |
| |
9056 | 9056 |
| |
9057 | 9057 |
| |
| 9058 | + | |
| 9059 | + | |
| 9060 | + | |
| 9061 | + | |
| 9062 | + | |
| 9063 | + | |
| 9064 | + | |
| 9065 | + | |
| 9066 | + | |
| 9067 | + | |
| 9068 | + | |
| 9069 | + | |
| 9070 | + | |
| 9071 | + | |
| 9072 | + | |
| 9073 | + | |
| 9074 | + | |
| 9075 | + | |
| 9076 | + | |
| 9077 | + | |
| 9078 | + | |
| 9079 | + | |
| 9080 | + | |
| 9081 | + | |
| 9082 | + | |
| 9083 | + | |
| 9084 | + | |
| 9085 | + | |
| 9086 | + | |
| 9087 | + | |
| 9088 | + | |
| 9089 | + | |
| 9090 | + | |
| 9091 | + | |
| 9092 | + | |
| 9093 | + | |
| 9094 | + | |
| 9095 | + | |
| 9096 | + | |
| 9097 | + | |
| 9098 | + | |
| 9099 | + | |
| 9100 | + | |
| 9101 | + | |
| 9102 | + | |
| 9103 | + | |
| 9104 | + | |
| 9105 | + | |
| 9106 | + | |
| 9107 | + | |
| 9108 | + | |
| 9109 | + | |
| 9110 | + | |
| 9111 | + | |
| 9112 | + | |
| 9113 | + | |
9058 | 9114 |
| |
9059 | 9115 |
| |
9060 | 9116 |
| |
| |||
12520 | 12576 |
| |
12521 | 12577 |
| |
12522 | 12578 |
| |
12523 |
| - | |
| 12579 | + | |
12524 | 12580 |
| |
12525 | 12581 |
| |
12526 | 12582 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1016 | 1016 |
| |
1017 | 1017 |
| |
1018 | 1018 |
| |
| 1019 | + | |
1019 | 1020 |
| |
1020 | 1021 |
| |
1021 | 1022 |
| |
| |||
1415 | 1416 |
| |
1416 | 1417 |
| |
1417 | 1418 |
| |
1418 |
| - | |
| 1419 | + | |
1419 | 1420 |
| |
1420 | 1421 |
| |
1421 | 1422 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
105 | 105 |
| |
106 | 106 |
| |
107 | 107 |
| |
| 108 | + | |
| 109 | + | |
| 110 | + | |
108 | 111 |
| |
109 | 112 |
| |
110 | 113 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
75 | 75 |
| |
76 | 76 |
| |
77 | 77 |
| |
| 78 | + | |
| 79 | + | |
| 80 | + | |
78 | 81 |
| |
79 | 82 |
| |
80 | 83 |
| |
|
Lines changed: 98 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4 | 4 |
| |
5 | 5 |
| |
6 | 6 |
| |
7 |
| - | |
8 |
| - | |
9 |
| - | |
10 |
| - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
| |||
54 | 54 |
| |
55 | 55 |
| |
56 | 56 |
| |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
57 | 145 |
| |
58 | 146 |
| |
59 | 147 |
| |
| |||
113 | 201 |
| |
114 | 202 |
| |
115 | 203 |
| |
| 204 | + | |
| 205 | + | |
| 206 | + | |
116 | 207 |
| |
117 | 208 |
| |
| 209 | + | |
| 210 | + | |
118 | 211 |
| |
119 | 212 |
| |
120 | 213 |
| |
| |||
149 | 242 |
| |
150 | 243 |
| |
151 | 244 |
| |
| 245 | + | |
152 | 246 |
| |
153 | 247 |
| |
154 | 248 |
|
0 commit comments
Comments
(0)