pdns icon indicating copy to clipboard operation
pdns copied to clipboard

auth: Small performance improvement for the LMDB backend

Open rgacogne opened this issue 3 years ago • 1 comments

Short description

This two commits improve the performance of the LMDB backend a bit (I remember seeing up to 10% reduction in CPU usage in an unrealistic benchmark):

  • avoid the allocation of a string in LMDBBackend::get()
  • reduce allocations and copies in DNSRecordContent::deserialize(): the move from a vector to a PacketBuffer prevents the memory from being zeroed while we are going to overwrite it right away. The change from MOADNSParser to PacketReader avoids the need to copy the header and the whole packet (allocation + copy), parse the qname again, as well as the allocation of a vector of records while we know we have only one of these.

Checklist

I have:

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

rgacogne avatar Apr 07 '22 13:04 rgacogne

I do note that in my testing I've seen that DNSRecordContent::masterMake is actually also very slow.

It can be, yes, and I hate that it yields a shared_ptr while most of the time we only need a unique_ptr. I have some ideas about that but it's going to have to wait a bit :) But note that MOADNSParser called DNSRecordContent::masterMake already, with this PR we just do less work around that call.

rgacogne avatar Apr 07 '22 14:04 rgacogne