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

rec: Add hashed indexes to the caches, for faster retrieval #6505

Merged
merged 5 commits into from
May 14, 2018

Conversation

rgacogne
Copy link
Member

Short description

Most of the lookups in the query (positive) and negative caches are done on the exact name only, and doing so using a hash is much more faster than using canonical ordering.
In both cases we still need canonical ordering to be able to wipe a domain and its subtree from the cache efficiently, but regular retrieval (cachecache, get()) doesn't.

Pros:

  • Faster retrieval: ~8x faster

Cons:

  • Increased memory usage: ~10% overhead worst case (entries with only one small record)
  • Slower insertion: 1.08x slower

Checklist

I have:

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

ret+= sizeof(*j); // XXX WRONG we don't know the stored size! j->size();
ret+=(unsigned int)i.d_qname.toString().length();
for(const auto& record : i.d_records)
ret+= sizeof(record); // XXX WRONG we don't know the stored size! j->size();
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Is this comment still relevant?
  2. j->size() has no meaning here

Copy link
Member

Choose a reason for hiding this comment

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

given #6447, maybe just remove the comment here

Copy link
Member Author

Choose a reason for hiding this comment

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

The comment is still relevant (agreed, j doesn't make sense anymore) until #6447 is merged so I'd rather keep it. I'll remove the j->size(); part.

@@ -51,7 +51,7 @@ bool NegCache::getRootNXTrust(const DNSName& qname, const struct timeval& now, N
ni->d_qtype == qtnull) {
// We have something
if ((uint32_t)now.tv_sec < ni->d_ttd) {
ne = *ni;
*ne = &(*ni);
Copy link
Contributor

Choose a reason for hiding this comment

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

damn knights

Copy link
Contributor

@ahupowerdns ahupowerdns left a comment

Choose a reason for hiding this comment

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

looks good. Straightforward and I think we can stand the 8% insertion slowdown and memory consequences.

@rgacogne rgacogne merged commit 1f8f899 into PowerDNS:master May 14, 2018
@rgacogne rgacogne deleted the rec-multi-index branch May 14, 2018 09:43
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.

4 participants