[nsd-users] Zonec: b64_pton performance

Martin Svec martin.svec at zoner.cz
Tue Feb 23 18:15:29 UTC 2010


during my tests of NSD I've found a bottleneck in "zonec" that is easy
to fix and has significant performance impact for signed zones. This
bottleneck is b64_pton in /compat/b64_pton.c. Because signed zonefiles
are full of base64-encoded RRSIG/DNSKEY records, base64 decoder
performance really matters here. Unfortunately, b64_pton implementation
shipped with NSD is quite poor. It calls strchr(Base64,ch) for every
input character, its fast path contains too many branches etc. Attached
I send a patch that fixes it. The patch precomputes a reverse mapping
table of base64 characters to avoid strchr and simplifies tests of
whitespaces and padding characters. It also splits b64_pton into two
functions, one for non-NULL target and the other for NULL target. Maybe
the function for NULL target could be omitted, but I wanted to keep 100%
compatibility with the original b64_pton. I welcome any comments
regarding it.

Test environment: ~65000 signed zones of our customers, 64-bit Gentoo
Linux, NSD 3.2.4, gcc 4.3.2, Intel Xeon X3350 @ 2.66GHz, all zone files
pre-cached in memory.

$ time zonec
real    0m40.098s (+- 0.1s)
user    0m38.264s
sys     0m1.797s

$ time zonec
real    0m28.056s (+- 0.2s)
user    0m26.285s
sys     0m1.703s

That is 30% improvement of zonec compilation time in our case.

Best regards

Martin Svec

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: b64-pton-optim.patch
URL: <http://lists.nlnetlabs.nl/pipermail/nsd-users/attachments/20100223/c20fbb20/attachment.ksh>

More information about the nsd-users mailing list