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

fast network membership check #2625

Merged
merged 1 commit into from
Jun 21, 2017
Merged

fast network membership check #2625

merged 1 commit into from
Jun 21, 2017

Conversation

rade
Copy link
Member

@rade rade commented Jun 21, 2017

The rendering code checks whether endpoint IPs are part of cluster-local networks. Due to the prevalence of endpoints - medium sized reports can contain many thousands of endpoints - this is performance critical. Alas the existing code performs the check via a linear scan of a list of networks. That is slow when there are more than a few, which will be the case in the context of k8s, since there the probes register service IPs as local /32 networks.

Here we change representation of the set of networks to a prefix tree (aka trie), which is well-suited for IP network membership checks since networks are in fact a bitstring prefixes.

The specific representation is a crit-bit tree, but that choice was purely based on implementation convenience - the chosen library is the only one I could find that directly supports IP networks.

In my benchmarks this change improves topology rendering performance of Weave Cloud production reports by 3-7%.

The rendering code checks whether endpoint IPs are part of
cluster-local networks. Due to the prevalence of endpoints - medium
sized reports can contain many thousands of endpoints - this is
performance critical. Alas the existing code performs the check via a
linear scan of a list of networks. That is slow when there are more
than a few, which will be the case in the context of k8s, since there
the probes register service IPs as local /32 networks.

Here we change representation of the set of networks to a prefix
tree (aka trie), which is well-suited for IP network membership checks
since networks are in fact a bitstring prefixes.

The specific representation is a crit-bit tree, but that choice was
purely based on implementation convenience - the chosen library is the
only one I could find that directly supports IP networks.
@rade rade requested a review from 2opremio June 21, 2017 02:07
@2opremio
Copy link
Contributor

Related: kubernetes/kubernetes#25533

@rade rade merged commit ef003d8 into master Jun 21, 2017
@rade rade deleted the fast-network-membership-check branch July 5, 2017 13:08
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