BIND 10 trac2875, updated. 5739858315f803a8be995976533c9eed3dc87797 [2875] Schedule how deep in cache the answer is
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Jul 18 08:19:43 UTC 2013
The branch, trac2875 has been updated
via 5739858315f803a8be995976533c9eed3dc87797 (commit)
from 080d32fe9f01fef3e864f8c33465eb20516f0856 (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 5739858315f803a8be995976533c9eed3dc87797
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Jul 18 10:13:59 2013 +0200
[2875] Schedule how deep in cache the answer is
-----------------------------------------------------------------------
Summary of changes:
src/bin/resolver/bench/fake_resolution.cc | 17 ++++++++++++++---
src/bin/resolver/bench/fake_resolution.h | 24 +++++++++++++++++++++++-
2 files changed, 37 insertions(+), 4 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/resolver/bench/fake_resolution.cc b/src/bin/resolver/bench/fake_resolution.cc
index e3d54a9..454d06c 100644
--- a/src/bin/resolver/bench/fake_resolution.cc
+++ b/src/bin/resolver/bench/fake_resolution.cc
@@ -38,6 +38,8 @@ const size_t cache_write_size = 10000;
// queries are found in the cache directly. Half of the rest needs just one
// upstream query. Etc.
const float chance_complete = 0.5;
+// How large a chance is that the answer is in this level of cache?
+const float cache_level = 0.5;
// Number of milliseconds an upstream query can take. It picks a random number
// in between.
const size_t upstream_time_min = 2;
@@ -45,14 +47,22 @@ const size_t upstream_time_max = 50;
FakeQuery::FakeQuery(FakeInterface& interface) :
interface_(&interface),
- outstanding_(false)
+ outstanding_(false),
+ cache_depth_(1)
{
// Schedule what tasks are needed.
// First, parse the query
steps_.push_back(Step(Compute, parse_size));
// Look into the cache if it is there
steps_.push_back(Step(CacheRead, cache_read_size));
+ while (cache_depth_ < interface.layers() &&
+ (1.0 * random()) / RAND_MAX > cache_level) {
+ ++cache_depth_;
+ }
while ((1.0 * random()) / RAND_MAX > chance_complete) {
+ // If we need to go upstream, it was not in the cache. So need to
+ // read through all the levels to know for sure.
+ cache_depth_ = interface.layers();
// Needs another step of recursion. Render the upstream query.
steps_.push_back(Step(Compute, render_size));
// Send it and wait for the answer.
@@ -88,8 +98,9 @@ FakeQuery::performTask(const StepCallback& callback) {
}
}
-FakeInterface::FakeInterface(size_t query_count) :
- queries_(query_count)
+FakeInterface::FakeInterface(size_t query_count, size_t layers) :
+ queries_(query_count),
+ layers_(layers)
{
BOOST_FOREACH(FakeQueryPtr& query, queries_) {
query = FakeQueryPtr(new FakeQuery(*this));
diff --git a/src/bin/resolver/bench/fake_resolution.h b/src/bin/resolver/bench/fake_resolution.h
index cf2219c..148bb94 100644
--- a/src/bin/resolver/bench/fake_resolution.h
+++ b/src/bin/resolver/bench/fake_resolution.h
@@ -124,6 +124,15 @@ public:
}
return (steps_.back().first);
}
+ /// \brief Task size of the next step.
+ ///
+ /// This is used for sending the task to remote end.
+ size_t nextTaskSize() const {
+ if (done()) {
+ isc_throw(isc::InvalidOperation, "We are done, no more tasks");
+ }
+ return (steps_.back().second);
+ }
/// \brief Move network communication to different interface.
///
/// By default, a query does all the "communication" on the interface
@@ -149,6 +158,10 @@ public:
void answerReceived() {
outstanding_ = false;
}
+ /// \brief How deep in the cache we need to go for cache read.
+ size_t cacheDepth() const {
+ return cache_depth_;
+ }
private:
// The scheduled steps for this task.
typedef std::pair<Task, size_t> Step;
@@ -159,6 +172,8 @@ private:
FakeInterface* interface_;
// Is an upstream query outstanding?
bool outstanding_;
+ // How deep in the cache we need to go for read.
+ size_t cache_depth_;
};
typedef boost::shared_ptr<FakeQuery> FakeQueryPtr;
@@ -188,7 +203,10 @@ public:
///
/// Initiarile the interface and create query_count queries for the
/// benchmark. They will be handed out one by one with receiveQuery().
- FakeInterface(size_t query_count);
+ /// The layers say how many layers the cache has, therefore how many
+ /// cache reads might be needed and how deep an update needs to be
+ /// sent.
+ FakeInterface(size_t query_count, size_t layers = 1);
/// \brief Wait for answers from upstream servers.
///
/// Wait until at least one "answer" comes from the remote server. This
@@ -211,6 +229,9 @@ public:
/// This returns a NULL pointer when there are no more queries to answer
/// (the number designated for the benchmark was reached).
FakeQueryPtr receiveQuery();
+ size_t layers() const {
+ return layers_;
+ }
private:
class UpstreamQuery;
friend class FakeQuery;
@@ -219,6 +240,7 @@ private:
size_t msec);
asiolink::IOService service_;
std::vector<FakeQueryPtr> queries_;
+ const size_t layers_;
};
}
More information about the bind10-changes
mailing list