forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit03023a2
committed
instr_time: Represent time as an int64 on all platforms
Until now we used struct timespec for instr_time on all platforms butwindows. Using struct timespec causes a fair bit of memory (struct timeval is16 bytes) and runtime overhead (much more complicated additions). Instead wecan convert the time to nanoseconds in INSTR_TIME_SET_CURRENT(), making theremaining operations cheaper.Representing time as int64 nanoseconds provides sufficient range, ~292 yearsrelative to a starting point (depending on clock source, relative to the unixepoch or the system's boot time). That'd not be sufficient for calendar timestored on disk, but is plenty for runtime interval time measurement.On windows instr_time already is represented as cycles. It might make sense torepresent time as cycles on other platforms as well, as using cycleacquisition instructions like rdtsc directly can reduce the overhead of timeacquisition substantially. This could be done in a fairly localized manner asthe code stands after this commit.Because the windows and non-windows paths are now more similar, use a commonset of macros. To make that possible, most of the use of LARGE_INTEGER had tobe removed, which looks nicer anyway.To avoid users of the API relying on the integer representation, we wrap the64bit integer inside struct struct instr_time.Author: Andres Freund <andres@anarazel.de>Author: Lukas Fittl <lukas@fittl.com>Author: David Geier <geidav.pg@gmail.com>Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/20230113195547.k4nlrmawpijqwlsa@awork3.anarazel.de1 parent25b2aba commit03023a2
1 file changed
+86
-76
lines changedLines changed: 86 additions & 76 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
34 | 34 |
| |
35 | 35 |
| |
36 | 36 |
| |
| 37 | + | |
| 38 | + | |
37 | 39 |
| |
38 | 40 |
| |
39 | 41 |
| |
| |||
54 | 56 |
| |
55 | 57 |
| |
56 | 58 |
| |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
57 | 82 |
| |
58 | 83 |
| |
| 84 | + | |
59 | 85 |
| |
60 | 86 |
| |
61 | 87 |
| |
| |||
80 | 106 |
| |
81 | 107 |
| |
82 | 108 |
| |
83 |
| - | |
84 |
| - | |
85 |
| - | |
86 |
| - | |
87 |
| - | |
88 |
| - | |
89 |
| - | |
90 |
| - | |
91 |
| - | |
92 |
| - | |
93 |
| - | |
94 |
| - | |
95 |
| - | |
96 |
| - | |
97 |
| - | |
98 |
| - | |
99 |
| - | |
100 |
| - | |
101 |
| - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
102 | 115 |
| |
103 |
| - | |
104 |
| - | |
105 |
| - | |
106 |
| - | |
107 |
| - | |
108 |
| - | |
109 |
| - | |
110 |
| - | |
111 |
| - | |
112 |
| - | |
113 |
| - | |
| 116 | + | |
| 117 | + | |
114 | 118 |
| |
115 |
| - | |
116 |
| - | |
117 |
| - | |
118 |
| - | |
119 |
| - | |
120 |
| - | |
121 |
| - | |
122 |
| - | |
123 |
| - | |
124 |
| - | |
125 |
| - | |
126 |
| - | |
127 |
| - | |
128 |
| - | |
129 |
| - | |
130 |
| - | |
| 119 | + | |
| 120 | + | |
131 | 121 |
| |
132 |
| - | |
133 |
| - | |
| 122 | + | |
| 123 | + | |
134 | 124 |
| |
135 |
| - | |
136 |
| - | |
| 125 | + | |
| 126 | + | |
137 | 127 |
| |
138 |
| - | |
139 |
| - | |
140 | 128 |
| |
141 | 129 |
| |
142 | 130 |
| |
143 |
| - | |
144 |
| - | |
145 |
| - | |
146 |
| - | |
147 |
| - | |
148 |
| - | |
149 |
| - | |
150 |
| - | |
151 |
| - | |
152 |
| - | |
153 |
| - | |
154 |
| - | |
155 |
| - | |
156 |
| - | |
157 |
| - | |
158 | 131 |
| |
159 |
| - | |
160 |
| - | |
| 132 | + | |
161 | 133 |
| |
162 |
| - | |
163 |
| - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
164 | 140 |
| |
165 |
| - | |
166 |
| - | |
| 141 | + | |
| 142 | + | |
167 | 143 |
| |
168 |
| - | |
169 |
| - | |
| 144 | + | |
| 145 | + | |
170 | 146 |
| |
171 | 147 |
| |
172 | 148 |
| |
| |||
177 | 153 |
| |
178 | 154 |
| |
179 | 155 |
| |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
180 | 162 |
| |
181 | 163 |
| |
182 |
| - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
183 | 173 |
| |
184 | 174 |
| |
185 | 175 |
| |
186 | 176 |
| |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
187 | 197 |
|
0 commit comments
Comments
(0)