calico
calico copied to clipboard
[RFC] Exact match for index
When a selector is used to choose the resource, some match operartor will decide the maxiumum scope of the resource.
For example, considering followed selector: a=='a1' && b in {'b1', 'b2'}
All the result is sure to meet a=='a1' requirement. If we index all the resource through the value for label 'a', the the flow will be:
- Use the index to find all the resource that meet a=='a1' through O(1) search,
- Evaluate all the result from step 1 with
b in {'b1', 'b2'}
Such search is sure to be much faster than the current full scan.
This patch includes:
-
Create an index for selector and an index for endpoint. Please notice that if the value is not found, then an empty value is used.
-
When matching a selector to a endpoint, check if any exact match is specified in the selector. If yes, get the value and use that value as index to figure out all the endpoint with the corresponding label/value pair.
-
When matching an endpoint to a selector, check if any exact match is specified in the endpoint's labels. If yes, get the value and use the value to find out all the selector. Please notice that we will search both selector with the corresponding value, or selector wit empty value, i.e. selector does not specify this label. This can be enhanced in future but let's keep it simple, since this matching is not the heaviest one.
On a LNP environment with 200k neteworkset and 200k networkpolicies, 60M extra memory added on the node on top of 2G.
Description
Related issues/PRs
Todos
- [ ] Tests
- [ ] Documentation
- [ ] Release note
Release Note
None required
@caseydavenport was this one on your radar?