BIND 10 trac2157, updated. 68caee89e543ffd406c8cd971ec1b15caeb63ce8 [2157] some optimization of statistics in query processing
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Sep 13 02:59:30 UTC 2012
The branch, trac2157 has been updated
via 68caee89e543ffd406c8cd971ec1b15caeb63ce8 (commit)
from 95af857989c47c89ecc77f4d69948bdecdfa14ac (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 68caee89e543ffd406c8cd971ec1b15caeb63ce8
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date: Wed Sep 12 20:10:06 2012 +0900
[2157] some optimization of statistics in query processing
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/auth_srv.cc | 44 +++++++++++++++++++-----------------
src/bin/auth/statistics.cc | 54 +++++---------------------------------------
src/bin/auth/statistics.h | 39 ++++++++++++++++++++++++++------
3 files changed, 61 insertions(+), 76 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/auth/auth_srv.cc b/src/bin/auth/auth_srv.cc
index 20bab27..7b8ccae 100644
--- a/src/bin/auth/auth_srv.cc
+++ b/src/bin/auth/auth_srv.cc
@@ -86,6 +86,7 @@ using namespace isc::asiolink;
using namespace isc::asiodns;
using namespace isc::server_common::portconfig;
using isc::auth::statistics::Counters;
+using isc::auth::statistics::QRAttributes;
namespace {
// A helper class for cleaning up message renderer.
@@ -273,6 +274,9 @@ public:
std::map<RRClass, boost::shared_ptr<ConfigurableClientList> >
client_lists_;
+ /// Query / Response attributes
+ QRAttributes stats_attrs_;
+
boost::shared_ptr<ConfigurableClientList> getClientList(const RRClass&
rrclass)
{
@@ -302,13 +306,10 @@ public:
///
/// \param server The DNSServer as passed to processMessage()
/// \param message The response as constructed by processMessage()
- /// \param stats_attrs query/response attributes for statistics which is
- /// not explained in \p messsage
/// \param done If true, it indicates there is a response.
/// this value will be passed to server->resume(bool)
void resumeServer(isc::asiodns::DNSServer* server,
isc::dns::Message& message,
- statistics::QRAttributes& stats_attrs,
const bool done);
private:
@@ -494,11 +495,11 @@ AuthSrv::processMessage(const IOMessage& io_message, Message& message,
OutputBuffer& buffer, DNSServer* server)
{
InputBuffer request_buffer(io_message.getData(), io_message.getDataSize());
- statistics::QRAttributes stats_attrs;
// statistics: check transport carrying the message (IP, transport)
- stats_attrs.setQueryIPVersion(io_message.getRemoteEndpoint().getFamily());
- stats_attrs.setQueryTransportProtocol(
+ impl_->stats_attrs_.setQueryIPVersion(
+ io_message.getRemoteEndpoint().getFamily());
+ impl_->stats_attrs_.setQueryTransportProtocol(
io_message.getRemoteEndpoint().getProtocol());
// First, check the header part. If we fail even for the base header,
@@ -509,13 +510,13 @@ AuthSrv::processMessage(const IOMessage& io_message, Message& message,
// Ignore all responses.
if (message.getHeaderFlag(Message::HEADERFLAG_QR)) {
LOG_DEBUG(auth_logger, DBG_AUTH_DETAIL, AUTH_RESPONSE_RECEIVED);
- impl_->resumeServer(server, message, stats_attrs, false);
+ impl_->resumeServer(server, message, false);
return;
}
} catch (const Exception& ex) {
LOG_DEBUG(auth_logger, DBG_AUTH_DETAIL, AUTH_HEADER_PARSE_FAIL)
.arg(ex.what());
- impl_->resumeServer(server, message, stats_attrs, false);
+ impl_->resumeServer(server, message, false);
return;
}
@@ -526,13 +527,13 @@ AuthSrv::processMessage(const IOMessage& io_message, Message& message,
LOG_DEBUG(auth_logger, DBG_AUTH_DETAIL, AUTH_PACKET_PROTOCOL_ERROR)
.arg(error.getRcode().toText()).arg(error.what());
makeErrorMessage(impl_->renderer_, message, buffer, error.getRcode());
- impl_->resumeServer(server, message, stats_attrs, true);
+ impl_->resumeServer(server, message, true);
return;
} catch (const Exception& ex) {
LOG_DEBUG(auth_logger, DBG_AUTH_DETAIL, AUTH_PACKET_PARSE_ERROR)
.arg(ex.what());
makeErrorMessage(impl_->renderer_, message, buffer, Rcode::SERVFAIL());
- impl_->resumeServer(server, message, stats_attrs, true);
+ impl_->resumeServer(server, message, true);
return;
} // other exceptions will be handled at a higher layer.
@@ -557,14 +558,14 @@ AuthSrv::processMessage(const IOMessage& io_message, Message& message,
io_message.getDataSize());
// statistics: check TSIG attributes
// SIG(0) is currently not implemented in Auth
- stats_attrs.setQuerySig(true, false,
- ( tsig_error == TSIGError::NOERROR() ));
+ impl_->stats_attrs_.setQuerySig(true, false,
+ tsig_error == TSIGError::NOERROR());
}
if (tsig_error != TSIGError::NOERROR()) {
makeErrorMessage(impl_->renderer_, message, buffer,
tsig_error.toRcode(), tsig_context);
- impl_->resumeServer(server, message, stats_attrs, true);
+ impl_->resumeServer(server, message, true);
return;
}
@@ -576,14 +577,15 @@ AuthSrv::processMessage(const IOMessage& io_message, Message& message,
{
ConstEDNSPtr edns = message.getEDNS();
if (edns != NULL) {
- stats_attrs.setQueryEDNS(true, edns->getVersion() == 0);
- stats_attrs.setQueryDO(edns->getDNSSECAwareness());
+ impl_->stats_attrs_.setQueryEDNS(true,
+ edns->getVersion() == 0);
+ impl_->stats_attrs_.setQueryDO(edns->getDNSSECAwareness());
}
}
// statistics: check OpCode
// note: This can only be reliable after TSIG check succeeds.
- stats_attrs.setQueryOpCode(opcode.getCode());
+ impl_->stats_attrs_.setQueryOpCode(opcode.getCode());
if (opcode == Opcode::NOTIFY()) {
send_answer = impl_->processNotify(io_message, message, buffer,
@@ -625,7 +627,7 @@ AuthSrv::processMessage(const IOMessage& io_message, Message& message,
LOG_DEBUG(auth_logger, DBG_AUTH_DETAIL, AUTH_RESPONSE_FAILURE_UNKNOWN);
makeErrorMessage(impl_->renderer_, message, buffer, Rcode::SERVFAIL());
}
- impl_->resumeServer(server, message, stats_attrs, send_answer);
+ impl_->resumeServer(server, message, send_answer);
}
bool
@@ -820,15 +822,15 @@ AuthSrvImpl::processUpdate(const IOMessage& io_message) {
void
AuthSrvImpl::resumeServer(DNSServer* server, Message& message,
- statistics::QRAttributes& stats_attrs,
const bool done)
{
if (done) {
- stats_attrs.answerHasSent();
+ stats_attrs_.answerHasSent();
// isTruncated from MessageRenderer
- stats_attrs.setResponseTruncated(renderer_.isTruncated());
+ stats_attrs_.setResponseTruncated(renderer_.isTruncated());
}
- counters_.inc(stats_attrs, message);
+ counters_.inc(stats_attrs_, message);
+ stats_attrs_.reset();
server->resume(done);
}
diff --git a/src/bin/auth/statistics.cc b/src/bin/auth/statistics.cc
index 0e5959d..552d73f 100644
--- a/src/bin/auth/statistics.cc
+++ b/src/bin/auth/statistics.cc
@@ -22,8 +22,7 @@
#include <cc/data.h>
#include <cc/session.h>
-#include <statistics/counter.h>
-#include <statistics/counter_dict.h>
+#include <boost/foreach.hpp>
#include <algorithm>
#include <cctype>
@@ -32,9 +31,6 @@
#include <sstream>
#include <iostream>
-#include <boost/noncopyable.hpp>
-#include <boost/foreach.hpp>
-
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -46,7 +42,6 @@ using namespace isc::auth;
using namespace isc::statistics;
namespace {
-using isc::statistics::Counter;
using isc::auth::statistics::Counters;
void
fillNodes(const Counter& counter, const char* const nodename[], const size_t size,
@@ -65,24 +60,7 @@ namespace isc {
namespace auth {
namespace statistics {
-class CountersImpl : boost::noncopyable {
-public:
- CountersImpl();
- ~CountersImpl();
- void inc(const QRAttributes& qrattrs, const Message& response);
- Counters::item_tree_type
- get(const Counters::item_node_name_set_type& trees) const;
- // Currently for testing purpose only
- Counters::item_tree_type dump() const;
-private:
- // counter for server
- Counter server_qr_counter_;
- Counter server_socket_counter_;
- // set of counters for zones
- CounterDictionary zone_qr_counters_;
-};
-
-CountersImpl::CountersImpl() :
+Counters::Counters() :
// initialize counter
// size of server_qr_counter_, zone_qr_counters_: QR_COUNTER_TYPES
// size of server_socket_counter_: SOCKET_COUNTER_TYPES
@@ -91,11 +69,11 @@ CountersImpl::CountersImpl() :
zone_qr_counters_(QR_COUNTER_TYPES)
{}
-CountersImpl::~CountersImpl()
+Counters::~Counters()
{}
void
-CountersImpl::inc(const QRAttributes& qrattrs, const Message& response) {
+Counters::inc(const QRAttributes& qrattrs, const Message& response) {
// protocols carrying request
if (qrattrs.req_ip_version_ == AF_INET) {
server_qr_counter_.inc(QR_REQUEST_IPV4);
@@ -230,7 +208,7 @@ CountersImpl::inc(const QRAttributes& qrattrs, const Message& response) {
}
Counters::item_tree_type
-CountersImpl::get(const Counters::item_node_name_set_type& trees) const {
+Counters::get(const Counters::item_node_name_set_type& trees) const {
using namespace isc::data;
Counters::item_tree_type item_tree = Element::createMap();
@@ -255,7 +233,7 @@ CountersImpl::get(const Counters::item_node_name_set_type& trees) const {
// Currently for testing purpose only
Counters::item_tree_type
-CountersImpl::dump() const {
+Counters::dump() const {
using namespace isc::data;
Counters::item_tree_type item_tree = Element::createMap();
@@ -266,26 +244,6 @@ CountersImpl::dump() const {
return (item_tree);
}
-Counters::Counters() : impl_(new CountersImpl())
-{}
-
-Counters::~Counters() {}
-
-void
-Counters::inc(const QRAttributes& qrattrs, const Message& response) {
- impl_->inc(qrattrs, response);
-}
-
-Counters::item_tree_type
-Counters::get(const Counters::item_node_name_set_type& trees) const {
- return (impl_->get(trees));
-}
-
-Counters::item_tree_type
-Counters::dump() const {
- return (impl_->dump());
-}
-
} // namespace statistics
} // namespace auth
} // namespace isc
diff --git a/src/bin/auth/statistics.h b/src/bin/auth/statistics.h
index 987a3db..59f7a9e 100644
--- a/src/bin/auth/statistics.h
+++ b/src/bin/auth/statistics.h
@@ -19,18 +19,20 @@
#include <dns/message.h>
+#include <statistics/counter.h>
+#include <statistics/counter_dict.h>
+
+#include <boost/noncopyable.hpp>
+
#include <string>
#include <set>
#include <stdint.h>
-#include <boost/scoped_ptr.hpp>
namespace isc {
namespace auth {
namespace statistics {
-class CountersImpl;
-
class QRAttributes {
/// \brief Query/Response attributes for statistics.
///
@@ -38,8 +40,8 @@ class QRAttributes {
/// for statistics data collection.
///
/// This class does not have getter methods since it exposes private members
-/// to \c CountersImpl directly.
-friend class CountersImpl;
+/// to \c Counters directly.
+friend class Counters;
private:
// request attributes
int req_ip_version_; // IP version
@@ -96,6 +98,9 @@ public:
/// \brief Set if the response is truncated.
/// \throw None
inline void setResponseTruncated(const bool is_truncated);
+ /// \brief Reset attributes.
+ /// \throw None
+ inline void reset();
};
inline QRAttributes::QRAttributes() :
@@ -157,6 +162,22 @@ QRAttributes::setResponseTruncated(const bool is_truncated) {
res_is_truncated_ = is_truncated;
}
+inline void
+QRAttributes::reset() {
+ req_ip_version_ = 0;
+ req_transport_protocol_ = 0;
+ req_opcode_ = 0;
+ req_is_edns_0_ = false;
+ req_is_edns_badver_ = false;
+ req_is_dnssec_ok_ = false;
+ req_is_tsig_ = false;
+ req_is_sig0_ = false;
+ req_is_badsig_ = false;
+ zone_origin_.clear();
+ answer_sent_ = false;
+ res_is_truncated_ = false;
+}
+
/// \brief Set of query counters.
///
/// \c Counters is set of query counters class. It holds query counters
@@ -181,9 +202,13 @@ QRAttributes::setResponseTruncated(const bool is_truncated) {
///
/// \todo Hold counters for each query types (Notify, Axfr, Ixfr, Normal)
/// \todo Consider overhead of \c Counters::inc()
-class Counters {
+class Counters : boost::noncopyable {
private:
- boost::scoped_ptr<CountersImpl> impl_;
+ // counter for server
+ isc::statistics::Counter server_qr_counter_;
+ isc::statistics::Counter server_socket_counter_;
+ // set of counters for zones
+ isc::statistics::CounterDictionary zone_qr_counters_;
public:
/// The constructor.
///
More information about the bind10-changes
mailing list