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

Don't create temporary strings to escape DNSName labels #8013

Merged
merged 1 commit into from Jul 3, 2019

Conversation

@rgacogne
Copy link
Member

@rgacogne rgacogne commented Jul 2, 2019

Short description

Shaves a nice 20%+ off DNSName::toString() for regular names, and cut in half the CPU time when we encounter a 'special' character (not . or \ and lesser or equal to 0x20 or greater or equal to 0x7f).

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)
Copy link
Member

@chbruyand chbruyand left a comment

LGTM, nice shave!

size_t pos = 0;

ret.reserve(len);
Copy link
Member

@chbruyand chbruyand Jul 2, 2019

Maybe this would be worth to keep reserve()ing enough space to append the escaped label ?

Copy link
Member

@omoerbeek omoerbeek Jul 3, 2019

I think that is covered by line 172. In the regular case that should be enough.

Copy link
Member Author

@rgacogne rgacogne Jul 3, 2019

In theory we should have reserved enough space already at the beginning of DNSName::toString(), but that might not be true due to escaping, I'll try to measure whether a ret.reserve(ret.size() + len) helps.

Copy link
Member

@chbruyand chbruyand Jul 3, 2019

I think that is covered by line 172. In the regular case that should be enough.

Yes indeed, my bad.

size_t pos = 0;

ret.reserve(len);
Copy link
Member

@omoerbeek omoerbeek Jul 3, 2019

I think that is covered by line 172. In the regular case that should be enough.

@omoerbeek omoerbeek merged commit 108dfce into PowerDNS:master Jul 3, 2019
23 checks passed
@rgacogne rgacogne deleted the dnsname-escapelabel-faster branch Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants