Commit 9c36a12
authored
perf(local): avoid loading the entire advisory unless it will actually be used (#2450)
Right now we always parse advisories even if we don't end up loading
them into the database, which is relatively expensive at scale so now we
use `gjson` to extract the subset of data we need from the raw bytes to
determine if the advisory is relevant before we do the advisory parsing.
This is especially useful for databases with a high amount of MAL
advisories since their packages are very rare, such as the NPM database
(which has 209647 MAL advisories out of a total of 214057 advisories) -
before this it takes about 10 seconds to do a scan, whereas after this
optimization it takes about 3 seconds1 parent d44e578 commit 9c36a12
File tree
2 files changed
+69
-15
lines changed- internal/clients/clientimpl/localmatcher
2 files changed
+69
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
160 | 162 | | |
161 | 163 | | |
162 | 164 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
169 | 173 | | |
170 | | - | |
171 | | - | |
172 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
173 | 181 | | |
174 | 182 | | |
175 | 183 | | |
| |||
197 | 205 | | |
198 | 206 | | |
199 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
200 | 214 | | |
201 | 215 | | |
202 | 216 | | |
203 | 217 | | |
204 | 218 | | |
205 | 219 | | |
206 | 220 | | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
| 221 | + | |
212 | 222 | | |
213 | 223 | | |
214 | 224 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
502 | 502 | | |
503 | 503 | | |
504 | 504 | | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
505 | 533 | | |
506 | 534 | | |
507 | 535 | | |
| |||
512 | 540 | | |
513 | 541 | | |
514 | 542 | | |
515 | | - | |
| 543 | + | |
516 | 544 | | |
517 | 545 | | |
518 | 546 | | |
| |||
545 | 573 | | |
546 | 574 | | |
547 | 575 | | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
548 | 592 | | |
549 | 593 | | |
0 commit comments