BIND 10 #1568: Change throw to assert to gain performance
BIND 10 Development
do-not-reply at isc.org
Fri Mar 9 22:45:46 UTC 2012
#1568: Change throw to assert to gain performance
-------------------------------------+-------------------------------------
Reporter: | Owner: jinmei
vorner | Status: reviewing
Type: | Milestone:
enhancement | Sprint-20120320
Priority: | Resolution:
medium | Sensitive: 0
Component: | Sub-Project: DNS
b10-auth | Estimated Difficulty: 0
Keywords: | Total Hours: 0
Defect Severity: N/A |
Feature Depending on Ticket: |
performance |
Add Hours to Ticket: 0 |
Internal?: 0 |
-------------------------------------+-------------------------------------
Comment (by jinmei):
Now the new `MessageRenderer` implementation is likely to need this,
I think it's time to resume this ticket.
First, I made a very minor editorial fix to the branch.
Second, I think we need a changelog for this because it could
potentially change observable behavior.
Third, I wonder we could do something similar to what I did in
trac1603: still throw on error but move the throw statement to a
separate private method:
{{{#!diff
- assert(pos < size_);
+ if (pos >= size_) {
+ throwError();
+ }
return (buffer_[pos]);
}
//@}
+private:
+ static void throwError() {
+ isc_throw(InvalidBufferPosition, "read at invalid position");
+ }
+public:
}}}
I've tested this on trac1603bench, and I saw it was slightly slower
than the assert() version, but the gap was not that big and I was not
sure if it was an experimental margin or the real difference due to
the implementation difference. At the moment I'm okay with keeping
the use of assert() if we want the highest possible performance, but
we might note the possibility of future extension where we use an
exception in a separate function.
Other than these, the branch is okay for merge.
--
Ticket URL: <http://bind10.isc.org/ticket/1568#comment:6>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development
More information about the bind10-tickets
mailing list