-
Notifications
You must be signed in to change notification settings - Fork 851
Improve performance of finding SNI Actions #9736
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
Conversation
| @@ -0,0 +1,46 @@ | |||
| /** @file | |||
|
|
|||
| Collection of utility functions for converting between different chars. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not call it CharConvert.h?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about StingConvert.h ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other candidate is TextConvert.h, but it sounds like utils for the TextView?
bdc647f to
db12c36
Compare
|
I don't understand how the flame graph is related to this PR. It might be interesting on it's own, if you could read more of the function names. Is it graphing data from gstack/pstack ? |
db12c36 to
eaf43b2
Compare
|
Is it really faster / simpler to downcase the strings vs. using a case insensitive comparison in the |
eaf43b2 to
853031a
Compare
|
I'm following what SSLCertLookup does for consistency. Initially, I used a custom hash and compare function, but I haven't seen significant differences. |
He would also have to write a custom hash to do the case conversion before accumulating each character. It's also tricky to avoid temporary strings generated from string_view or null terminated strings with maps of strings. |
|
I've been kicking around the idea in my head that generating a single DFA to match against a list of strings with wild cards would only be medium hard. It would probably be faster than what we're doing (a DFA per string). Even if the strings had no wildcards, it might be competitive with an unordered_map of the strings. Another idea is to OR together all the strings into one expression, and see what sort of DFA pcre could generate from that. |
|
There are a ton of approaches to optimize the lookup function, but we can do it later. This change fixes the 27% drop at least, let's ship this first. |
|
I'm hearing that other Yahoo people want to have input on this. |
|
It sounds like @JosiahWI's patch to add incoming port ranges to sni.yaml may provide a way to address this: The suggestion from @maskit (see #9767 (comment)) is that we can add a separate directive for servername's with patterns that pcre would apply to versus plain sni literals. That way the latter would not run through the pcre logic. |
|
The detection of wildcards is very simple ( https://github.com/apache/trafficserver/pull/9736/files#diff-abc27229b33119467f5ec2357eac6a114e5e874fe6db8ce5014c3920683c1ac8R119 ) so I'm not understanding why we would need a distinct key for FQDNs with wildcards. |
That makes sense. Can you please add your comment to the discussion here: |
Hmm from the code I don't see that a new YAML key is added for FQDNs with wildcards. Only a new key for incoming port range. |
@JosiahWI was planning to do that as a separate commit. |
|
I'm not sure if we all are on the same page. The two keys I suggested on #9767 are, one for the standard way, and one for current pcre pattern matching. The both can use * but in different ways.
If we currently allows use of PCRE, checking * is not enough and it can cause problems if somebody use other pattern matching stuff (i.e. |
|
We also have the alternative of eliminating regular expressions entirely. Instances of this class encode a pattern with zero or more arbitrarily-located wildcards. (So zero wildcards does not have to be handled as a special case. There are some corner cases to keep in mind. The above code would not consider |
|
Seems like this is turning into a case of the ideal being the enemy of the good. I'll wait till Monday to approve it, to give anyone who wants to a last chance to request changes. |
There is currently an dev mailing list email discussion about this with subject "[Discussion/Proposal] Regex support in sni.yaml". |
Yes, if it (ever) converges on an alternative, we can substitute the alternative for this change. |
|
The discussion is still going on, but an important comment is "the policy match depends on the order of entries". This PR is missing that point, and we need to support it anyway. I'll follow what remap config does when we reach a consensus. |
e3dd725 to
7bab636
Compare
|
Now, this PR has
|
7bab636 to
e213211
Compare
f6cac32 to
6c380b2
Compare
6c380b2 to
faf317a
Compare

Summary
@c-taylor found a performance issue with SNI Action lookup. If we have a lot of configs(FQDNs) in sni.yaml, it spends time on
pcre_exec. Because ATS traverses theSNIList sni_action_list.Benchmark & Flamegraph
My benchmark says 27% drop in throughput (req/sec) with 400 FQDNs in the sni.yaml.
Approach
Add a
std::unordered_mapfor the exact match. This is similar to what we have with certification lookup.The wildcard cases are left as is in the
SNIList sni_action_listfor compatibility.