Add allocator to all public functions to improve performance #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This allowed to speed up lookups from ~85K/s to ~656K/s by reusing the arena allocator in the benchmark.
examples/benchmark.zig
Download
GeoLite2-City.mmdb
, add the benchmark tobuild.zig
, and runzig build example_benchmark -Doptimize=ReleaseFast
.new
$ zig build example_benchmark -Doptimize=ReleaseFast Benchmarking with: Database: GeoLite2-City.mmdb Lookups: 1000000 Opening database... Database opened successfully in 0.04715 ms. Type: GeoLite2-City Starting benchmark... --- Benchmark Finished --- Total Lookups Attempted: 1000000 Successful Lookups: 859161 IPs Not Found: 140839 Lookup Errors: 0 Elapsed Time: 1.523236271 s Lookups Per Second (avg):656496.9722940638
old
zig build example_benchmark -Doptimize=ReleaseFast Benchmarking with: Database: GeoLite2-City.mmdb Lookups: 1000000 Opening database... Database opened successfully in 0.0484 ms. Type: GeoLite2-City Starting benchmark... --- Benchmark Finished --- Total Lookups Attempted: 1000000 Successful Lookups: 859163 IPs Not Found: 140837 Lookup Errors: 0 Elapsed Time: 11.745747762 s Lookups Per Second (avg):85137.19349867305