Thanks to visit codestin.com
Credit goes to github.com

Skip to content

chore: speed up vuln sync#141

Merged
andrew merged 1 commit intogit-pkgs:mainfrom
miketheman:miketheman/sync-vulns
Mar 2, 2026
Merged

chore: speed up vuln sync#141
andrew merged 1 commit intogit-pkgs:mainfrom
miketheman:miketheman/sync-vulns

Conversation

@miketheman
Copy link
Contributor

With the added automatic sync behavior introduced in #132, we can now experience the latency when the vulnerability data isn't cached.

This refactor does a few things:

  • Add test coverage for syncVulnerabilitiesForDeps by extending the signature to accept an injected source database instead of having to instantiate inline
  • Batch-collection of vulnerabilities in groups of 20 to speed up total execution time for large volumes of dependencies
  • Console progress updater while downloading so the user gets some visual feedback

With the added automatic sync behavior introduced in git-pkgs#132, we can now
experience the latency when the vulnerability data isn't cached.

This refactor does a few things:

- Add test coverage for `syncVulnerabilitiesForDeps` by extending the
  signature to accept an injected `source` database instead of having to
  instantiate inline
- Batch-collection of vulnerabilities in groups of 20 to speed up total
  execution time for large volumes of dependencies
- Console progress updater while downloading so the user gets some
  visual feedback

Signed-off-by: Mike Fiedler <[email protected]>
@miketheman
Copy link
Contributor Author

@andrew This is another bot-guided improvement I came up with, and found some speed and UX gains.

With these changes, and on this repository, here's a performance run on my machine:

$ hyperfine --min-runs 3 'git pkgs vulns sync --force' './git-pkgs vulns sync --force' --export-json vuln-scan.json
Benchmark 1: git pkgs vulns sync --force
  Time (mean ± σ):     13.156 s ±  1.922 s    [User: 0.219 s, System: 0.190 s]
  Range (min … max):   11.055 s … 14.826 s    3 runs

Benchmark 2: ./git-pkgs vulns sync --force
  Time (mean ± σ):      2.061 s ±  0.300 s    [User: 0.091 s, System: 0.065 s]
  Range (min … max):    1.767 s …  2.367 s    3 runs

Summary
  ./git-pkgs vulns sync --force ran
    6.38 ± 1.32 times faster than git pkgs vulns sync --force

(visualized)

@andrew
Copy link
Contributor

andrew commented Mar 2, 2026

Nice, i love a speedup with benchmarks!

Do you want to wait on this being merged so it uses #142

@miketheman
Copy link
Contributor Author

Nice, i love a speedup with benchmarks!

Do you want to wait on this being merged so it uses #142

I'm fine shipping this as-is, I don't know when I'll swing back to that one, and that PR will likely refactor this code anyhow.

@andrew andrew merged commit ba39eeb into git-pkgs:main Mar 2, 2026
4 checks passed
@miketheman miketheman deleted the miketheman/sync-vulns branch March 2, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants