Repository navigation
Use a radix trie for IX prefix lookup - #85
Merged
Merged
Conversation
Replace the linear scan over all PeeringDB IX prefixes with per-family binary radix tries keyed on address bits. Lookup now walks at most one node per address bit, so matching costs O(prefix_len) — at most 32 steps for IPv4 and 128 for IPv6 — instead of O(n) over the full prefix list (roughly 2,000 prefixes per miss with the old sorted-vec scan). Tries store indices into a shared IxInfo vec at terminal nodes and track the deepest match during descent, preserving longest-prefix-match semantics. Separate IPv4/IPv6 tries preserve the address-family separation that IpNetwork::contains provided. The public IxLookup API is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Implements the roadmap item IX lookup performance — radix trie for O(prefix_len) instead of O(n) linear scan.
src/lookup/ix.rswith a hand-rolled binary radix trie (flat node arena, no new dependencies): separate IPv4/IPv6 tries, terminal nodes index into the sharedIxInfovec, longest-prefix-match tracked during descentIxLookup::new/lookup/refresh_cache,run_ix_worker,CacheStatus) — zero call-site editsTesting
16 ix tests pass (new: IPv4/IPv6 match + non-match, nested /8–/16–/24 longest-prefix-match, overlapping IPv6 /32+/48, /32 and /128 host prefixes, family separation, empty trie). Full suite green; fmt + clippy -D warnings clean.