BIND 10 #536: Make OutputBuffer more lightweight
BIND 10 Development
do-not-reply at isc.org
Thu Apr 7 09:20:19 UTC 2011
#536: Make OutputBuffer more lightweight
-------------------------------------+-------------------------------------
Reporter: vorner | Owner: shane
Type: task | Status: accepted
Priority: major | Milestone:
Component: | Sprint-20110419
DNSPacket API | Resolution:
Keywords: | Sensitive: 0
Estimated Number of Hours: 7.0 | Add Hours to Ticket: 0
Billable?: 1 | Total Hours: 0
Internal?: 0 |
-------------------------------------+-------------------------------------
Changes (by shane):
* owner: UnAssigned => shane
* status: reviewing => accepted
Comment:
I had a quick look through this.
One actual point:
We check for buffer size of 0 in ensureAllocated(), but not in our
constructor(s). malloc() may return NULL in some cases if we try to
allocate 0 bytes, but not always (it's up to the system). I think we
should either explicitly disallow zero-sized buffers or we should check
for 0-bytes and set our buffer to NULL rather than try malloc(). (The
realloc() command always works, since we always insure at least 1024
bytes.)
We may want to experiment with reference counts and copy-on-write rather
than actual memory allocation in our assignment operators if we need
further optimizations here in the future. :)
I know this code hasn't changed, but I wonder if this:
{{{
buffer_[size_ ++] = static_cast<uint8_t>((data & 0xff00U) >> 8);
buffer_[size_ ++] = static_cast<uint8_t>(data & 0x00ffU);
}}}
Might be more efficient if written as array access somehow rather than bit
shifting. Hopefully modern compilers optimize that away, but maybe some
micro-benchmarking would reveal more.
--
Ticket URL: <https://bind10.isc.org/ticket/536#comment:8>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development
More information about the bind10-tickets
mailing list