Skip to content

Improve performance and consistency of alias lookups #611

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexbakker
Copy link

The current alias lookup implementation adds a separate entry to the lookup map for each IP address in the network of the alias. That's a lot of map entries for, say, a /16 network. This map becomes even larger if add_captid_to_resolve is enabled. This patch replaces this with a treap-based lookup.

The improvement in performance depends on how many aliases you have and how large your networks are. For our setup with ~80 aliases and a fair number of /19 and /22 networks, the speedup amounts to about 3x.

Alias lookups are now also more consistent. For aliases with partially overlapping networks, the alias with the longest prefix match wins, not the one that happens to be the last one to be added to the lookup map.

The new cidrtree dependency bumps the minimum Go version to 1.21.

Looks like it has been a while since the code base was formatted with gofmt, so this patch unfortunately also includes some formatting changes for the changed files.

@CLAassistant
Copy link

CLAassistant commented Apr 17, 2025

CLA assistant check
All committers have signed the CLA.

@lmangani
Copy link
Member

Thanks for this awesome improvement @alexbakker we appreciate it! We'll review and test as soon as possible 👍

The current alias lookup implementation adds a separate entry to the lookup map
for each IP address in the network of the alias. That's *a lot* of map entries
for, say, a ``/16`` network. This map becomes even larger if
``add_captid_to_resolve`` is enabled. This patch replaces this with a
treap-based lookup.

The improvement in performance depends on how many aliases you have and how
large your networks are. For our setup with ~80 aliases and a fair number of
``/19`` and ``/22`` networks, the speedup amounts to about 3x.

Alias lookups are now also more consistent. For aliases with partially
overlapping networks, the alias with the longest prefix match wins, not the one
that happens to be the last one to be added to the lookup map.

The new ``cidrtree`` dependency bumps the minimum Go version to 1.21.

Looks like it has been a while since the code base was formatted with gofmt, so
this patch unfortunately also includes some formatting changes for the changed
files.
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.

3 participants