Commit fa67ec6
committed
pkg/query: Improve filter performance
1) Only lowercase and convert filter string to bytes once.
2) Run filter on dictionary only and then match indices.
3) Run filter on all lines of a sample's locations at once to exit loop
earlier.
Filtering itself is 52% faster.
```
$ benchstat old.txt new.txt
name old time/op new time/op delta
FilterProfileData-10 0.05ns ± 1% 0.02ns ± 4% -52.41% (p=0.000 n=10+10)
```
And requests in total that filter about 17%.
```
$ benchstat old.txt new.txt
name old time/op new time/op delta
ColumnQueryAPIQueryFiltered-10 136ms ± 3% 112ms ± 4% -17.62% (p=0.008 n=5+5)
```1 parent 57e1275 commit fa67ec6
1 file changed
+23
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
282 | | - | |
| 282 | + | |
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | | - | |
| 288 | + | |
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
306 | | - | |
| 306 | + | |
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
319 | 330 | | |
320 | 331 | | |
321 | 332 | | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
329 | 342 | | |
330 | 343 | | |
331 | 344 | | |
| |||
0 commit comments