-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
FQDN: pick some low-hanging performance fruit #29691
Conversation
4426792
to
3200ea9
Compare
This is a simple benchmark that determine's the NameManager's contribution to the FQDN response flow. Signed-off-by: Casey Callendrello <cdc@isovalent.com>
We were doing needless sorting and searching to determine uniqueness. Only determine unique IDs when necessary. And, switch to using sets.Set for uniqueness. It uses more memory, but a lot less CPU and fewer allocations. Signed-off-by: Casey Callendrello <cdc@isovalent.com>
This code is on the critical path for DNS responses. By not sorting, we can save up to 50% of time spent in the NameManager. Signed-off-by: Casey Callendrello <cdc@isovalent.com>
Looking at CPU and memory profiling, this throwaway debug message was taking up to 50% of memory and a good chunk of CPU. Don't even bother allocating the logrus.Fields object unless we know we'll log. Signed-off-by: Casey Callendrello <cdc@isovalent.com>
3200ea9
to
92e054b
Compare
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.
Aswesome, thanks! I'm a low confidence reviewer, but this looks good to me overall. Only one thing which is unclear to me.
I would also be curious to see benchmarks for different data set sizes. While I expect a hashmap to be more efficient for large-ish sets of IPs, I would also expect that if there is only a hand full IPs that the old slice+sort approach might be faster.
/test |
This fixes some low-hanging-fruit, performance-wise, of the FQDN subsystem. It introduces a benchmark that stresses
NameManager.UpdateGeneratedDNS()
, which is in the critical path (and behind a lock!) for returning DNS responses.The changes are:
logrus.Fields
object just to skip at non-Debug level.Benchmark results: