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

dnsdist: Improve the scalability of MaxQPSIPRule() #12537

Merged
merged 4 commits into from
Feb 14, 2023

Conversation

rgacogne
Copy link
Member

Short description

This PR:

  • add a check to prevent several threads from cleaning up the IP database at the same time (the threads are serialized by a lock, but they would still do the work twice for no good reason) ;
  • make lookups roughly 50% faster by using a hashed index instead of an ordered one ;
  • divide the IP database in separate shards, using the new hash index, to reduce lock contention: this increases the performance of the rule up to 6 times in my tests (20 threads, 10 shards)

Hopefully closes #10124.

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)

/* entries are ordered from least recently seen to more recently
seen, as soon as we see one that has not expired yet, we are
done */
lookedAt++;

Check notice

Code scanning / CodeQL

For loop variable changed in body

Loop counters should not be modified in the body of the [loop](1).
Copy link
Member

@chbruyand chbruyand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@rgacogne rgacogne merged commit ba2cd6c into PowerDNS:master Feb 14, 2023
@rgacogne rgacogne deleted the ddist-faster-maxqpsiprule branch February 14, 2023 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dnsdist: Review performance impact of MaxQPSIPRule()
2 participants