[bind10-dev] possible premature optimization on OutputBuffer (#536)

JINMEI Tatuya / 神明達哉 jinmei at isc.org
Tue Apr 12 08:40:59 UTC 2011


I'm afraid the changes introduced in Trac #536 were premature
optimization.  It replaced the internal storage for the OutputBuffer
class from std::vector to a plain old array with in-house logic of
extending the array.

According to the description of the ticket, this was based on the
observation that "OutputBuffer::operator[] function takes 25% of our
running time".  In my general understanding of the code, the only
place (or at least the only place that could substantially affect
performance) where operator[] is used is inside the MessageRenderer
class, as a backend of name compression.

For full performance optimization it'll be quite likely that we should
revisit the way of name compression (perhaps for a particular type of
data source).  And, by optimizing name compression we may be able to
avoid calling the expensive operator[] for character-by-character
comparison.  For example, my experimental optimization didn't use it.

On the other hand, the changes in #536 require understanding of
additional buffer operations such as the ensureAllocated() method (to
those who need to understand the implementation of the class or debug
it)  I thought we generally try to avoid having such in house logic
when external/standard library can provide the functionality nicely.

I don't deny the possibility that we may still want to introduce micro
optimization to the buffer class after introducing all possible higher
level optimization, considering this should definitely be one major
bottleneck of DNS message handling.  But at least for now it seems to
introduce a premature optimization with making the code more
complicated for the gain that can be marginal in terms of overall
optimization.

I don't request canceling #536 right now, but if the above concern of
mine is shared with others, I suggest we revisit the internal of this
class once we introduce other higher level optimizations and perform
revised benchmark based on that code.

---
JINMEI, Tatuya



More information about the bind10-dev mailing list