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

Choose a reason for hiding this comment

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

LGTM, nice shave!

size_t pos = 0;

ret.reserve(len);
Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

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
@rgacogne rgacogne deleted the dnsname-escapelabel-faster branch July 3, 2019 12:16
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.

None yet

3 participants