- added dnstapEncoder object which incapsulates marshalling of dnstap
messages to protobuf and writing data to connection
- dnstapEncoder writes data directly to connection object. It doesn't
use the framestream's "write" method, because it writes data to
intermediate buffer (bufio.Writer) which leads to unnecessary
data copying and drops the performance
- dnstapEncoder reuses a preallocated buffer for marshalling dnstap
messages. Many messages are added to the same buffer. They are
separated with a "frame length" 4-byte values, so the buffer content
is writen to connection object in the format compatible with
framestream library
- added test which guarantees that dnstapEncoder output is the same
as framestream Encoder output
- the performance increase is about 50% in (dio *dnstapIO) serve() method
of dnstap plugin. The overall coredns performance increase is about 10%
in the following configuration:
.:1053 {
erratic {
drop 0
truncate 0
delay 0
}
dnstap tcp://127.0.0.1:6000 full
errors stdout
}
tested with dnsperf tool