forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0aba255
committed
Add optimized C string hashing
Given an already-initialized hash state and a NUL-terminated string,accumulate the hash of the string into the hash state and return thelength for the caller to (optionally) save for the finalizer. Thisavoids a strlen call.If the string pointer is aligned, we can use a word-at-a-timealgorithm for NUL lookahead. The aligned case is only used on 64-bitplatforms, since it's not worth the extra complexity for 32-bit.Handling the tail of the string after finishing the word-wise loopwas inspired by NetBSD's strlen(), but no code was taken since thatis written in assembly language.As demonstration, use this in the search path cache. This brings thegeneral case performance closer to the special case optimization donein commita86c61c. There are other places that could benefit, butthat is left for future work.Jeff Davis and John NaylorReviewed by Heikki Linnakangas, Jian He, Junwang ZhaoDiscussion:https://postgr.es/m/3820f030fd008ff14134b3e9ce5cc6dd623ed479.camel%40j-davis.comDiscussion:https://postgr.es/m/b40292c99e623defe5eadedab1d438cf51a4107c.camel%40j-davis.com1 parente97b672 commit0aba255
File tree
2 files changed
+145
-5
lines changed- src
- backend/catalog
- include/common
2 files changed
+145
-5
lines changedLines changed: 15 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
41 | 41 |
| |
42 | 42 |
| |
43 | 43 |
| |
44 |
| - | |
| 44 | + | |
45 | 45 |
| |
46 | 46 |
| |
47 | 47 |
| |
| |||
253 | 253 |
| |
254 | 254 |
| |
255 | 255 |
| |
256 |
| - | |
257 |
| - | |
| 256 | + | |
| 257 | + | |
258 | 258 |
| |
259 |
| - | |
260 |
| - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
261 | 271 |
| |
262 | 272 |
| |
263 | 273 |
| |
|
Lines changed: 130 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 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
61 | 79 |
| |
62 | 80 |
| |
63 | 81 |
| |
| |||
151 | 169 |
| |
152 | 170 |
| |
153 | 171 |
| |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
154 | 284 |
| |
155 | 285 |
| |
156 | 286 |
| |
|
0 commit comments
Comments
(0)