Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use bart algorithm for less memory usage + speed improvements #90

Merged
merged 2 commits into from
Jun 17, 2024

Conversation

Ice3man543
Copy link
Member

@Ice3man543 Ice3man543 commented Jun 17, 2024

  • Replaced cidranger package with bart which provides a faster + more memory optimized lookup algorithm
  • Improves memory usage as well as lookup speed by magnitudes

Benchmark results below

goos: darwin
goarch: arm64
pkg: github.com/projectdiscovery/networkpolicy
Benchmark_Networkpolicy_CIDRRanger
Benchmark_Networkpolicy_CIDRRanger-10              66189             16658 ns/op           12896 B/op        620 allocs/op
Benchmark_Networkpolicy_BartAlgorithm
Benchmark_Networkpolicy_BartAlgorithm-10          409262              2786 ns/op            3200 B/op         73 allocs/op
PASS

References

@Ice3man543 Ice3man543 requested a review from Mzack9999 June 17, 2024 09:12
@Ice3man543 Ice3man543 self-assigned this Jun 17, 2024
@Ice3man543 Ice3man543 linked an issue Jun 17, 2024 that may be closed by this pull request
@Ice3man543 Ice3man543 added the Status: Review Needed The issue has a PR attached to it which needs to be reviewed label Jun 17, 2024
@Mzack9999 Mzack9999 merged commit 496a450 into main Jun 17, 2024
2 checks passed
@Mzack9999 Mzack9999 deleted the use-bart-algorithm-speedup branch June 17, 2024 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Review Needed The issue has a PR attached to it which needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

High resident memory usage as well as slow lookups improvements
2 participants