BIND 10 trac2875, updated. 8a3642141f38a28ef32f60a26369999534e30312 [2875] Run up to 10 workers

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Jul 22 08:12:55 UTC 2013


The branch, trac2875 has been updated
       via  8a3642141f38a28ef32f60a26369999534e30312 (commit)
       via  fd052b9538958080167f00eeecb9c4eda8dcbd41 (commit)
       via  f9de8167523b24d2a49ee119f2b4e71e647c9479 (commit)
       via  b3473c1be9aece7564a5468761b8533dc091999c (commit)
      from  c6379673023f116daca5e88da140178949a655ed (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 8a3642141f38a28ef32f60a26369999534e30312
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Jul 22 10:11:58 2013 +0200

    [2875] Run up to 10 workers

commit fd052b9538958080167f00eeecb9c4eda8dcbd41
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Jul 22 10:07:06 2013 +0200

    [2875] Compute the correct count of children

commit f9de8167523b24d2a49ee119f2b4e71e647c9479
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Jul 22 10:06:04 2013 +0200

    [2875] Stop the IOService explicitly
    
    It seems it doesn't want to stop by simply running out of work. Stop
    explicitly when we have no more children.

commit b3473c1be9aece7564a5468761b8533dc091999c
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Jul 22 10:03:04 2013 +0200

    [2875] Handle cache depths
    
    Propagate the depth towards the workers and generate the queries of
    various depths.
    
    Off-by-one error in cache depths fixed.

-----------------------------------------------------------------------

Summary of changes:
 src/bin/resolver/bench/layers.cc |   35 +++++++++++++++++++++++------------
 src/bin/resolver/bench/layers.h  |    5 +++--
 src/bin/resolver/bench/main.cc   |    4 ++--
 3 files changed, 28 insertions(+), 16 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/resolver/bench/layers.cc b/src/bin/resolver/bench/layers.cc
index bac612f..3f38926 100644
--- a/src/bin/resolver/bench/layers.cc
+++ b/src/bin/resolver/bench/layers.cc
@@ -33,7 +33,7 @@ LayerResolver::LayerResolver(size_t count, size_t worker_count,
                              size_t fanout) :
     total_count_(count),
     top(new Subprocess(boost::bind(&LayerResolver::spawn, this, count,
-                                   worker_count, fanout, _1)))
+                                   worker_count, fanout, _1, 1)))
 {
     // Wait for the subprocess to become ready
     const std::string& ready = top->read(1);
@@ -53,8 +53,8 @@ struct Command {
 
 void
 sendQuery(const FakeQueryPtr& query, int cache_comm, int cache_depth) {
-    if (cache_depth == 0) {
-        // No caches to send to, ignore
+    if (cache_depth <= 1) {
+        // No caches to send to, ignore (local cache handled this one)
         return;
     }
     // Fill in the command
@@ -117,8 +117,8 @@ handleQuery(FakeQueryPtr query, Coroutine::caller_type& scheduler,
 }
 
 void
-LayerResolver::worker(size_t count, int channel) {
-    FakeInterface interface(count); // TODO Initialize the cache depth.
+LayerResolver::worker(size_t count, int channel, size_t depth) {
+    FakeInterface interface(count, depth);
     // We are ready
     ssize_t result = send(channel, "R", 1, 0);
     assert(result == 1);
@@ -144,15 +144,20 @@ namespace {
 class Child : boost::noncopyable {
 public:
     Child(const boost::function<void(int)>& main,
-          isc::asiolink::IOService& service, int parent) :
+          isc::asiolink::IOService& service, int parent,
+          size_t& child_count) :
         subprocess_(main),
+        service_(service),
         socket_(service, subprocess_.channel()),
         parent_(parent),
+        child_count_(child_count),
         signal_buffer_('\0')
     {}
     Subprocess subprocess_;
+    asiolink::IOService& service_;
     asiolink::LocalSocket socket_;
     int parent_;
+    size_t& child_count_;
     char signal_buffer_;
     Command command_buffer_;
     // Read signal from the child (eg. command header)
@@ -161,6 +166,9 @@ public:
         if (signal_buffer_ == 'F') {
             // The child finished it's work. Don't re-schedule
             // read.
+            if (-- child_count_ == 0) { // It's the last child.
+                service_.stop();
+            }
             return;
         } else if (signal_buffer_ == 'W') {
             // Write to cache. Read parameters.
@@ -177,7 +185,7 @@ public:
             dummy_work();
         }
         // Send the command to upper cache, if it should go there.
-        if (-- command_buffer_.levels > 0) {
+        if (-- command_buffer_.levels > 1) {
             const size_t bufsize = sizeof signal_buffer_ +
                 sizeof command_buffer_;
             uint8_t sendbuf[bufsize];
@@ -200,11 +208,11 @@ public:
 
 void
 LayerResolver::spawn(size_t count, size_t worker_count, size_t fanout,
-                     int channel)
+                     int channel, size_t depth)
 {
     if (worker_count == 1) {
         // We are the single worker
-        worker(count, channel);
+        worker(count, channel, depth);
     } else {
         if (fanout > worker_count) {
             // Just correction, so we don't spawn more children than needed
@@ -215,15 +223,18 @@ LayerResolver::spawn(size_t count, size_t worker_count, size_t fanout,
         // How much of these was satisfied
         size_t count_handled = 0;
         size_t workers_handled = 0;
+        size_t child_count = 0;
         for (size_t i = 0; i < fanout; ++i) {
             // How many to assign to this child
             size_t count_local = (count * (i+1)) / fanout - count_handled;
-            size_t workers_local = (count * (i+1)) / fanout - workers_handled;
+            size_t workers_local = (worker_count * (i+1)) / fanout -
+                workers_handled;
             // Initialize the child and make sure it is ready
             Child* child = new Child(boost::bind(&LayerResolver::spawn, this,
                                                  count_local, workers_local,
-                                                 fanout, _1), service,
-                                     channel);
+                                                 fanout, _1, depth + 1),
+                                     service, channel, child_count);
+            ++child_count;
             children.push_back(child);
             const std::string& ready = child->subprocess_.read(1);
             assert(ready == "R");
diff --git a/src/bin/resolver/bench/layers.h b/src/bin/resolver/bench/layers.h
index 9afaf8a..7950d3e 100644
--- a/src/bin/resolver/bench/layers.h
+++ b/src/bin/resolver/bench/layers.h
@@ -31,8 +31,9 @@ public:
     ~LayerResolver();
     size_t run();
 private:
-    void spawn(size_t count, size_t worker_count, size_t fanout, int channel);
-    void worker(size_t count, int channel);
+    void spawn(size_t count, size_t worker_count, size_t fanout, int channel,
+               size_t depth);
+    void worker(size_t count, int channel, size_t depth);
     size_t total_count_;
     Subprocess* top;
 };
diff --git a/src/bin/resolver/bench/main.cc b/src/bin/resolver/bench/main.cc
index f6f43a5..3288ac0 100644
--- a/src/bin/resolver/bench/main.cc
+++ b/src/bin/resolver/bench/main.cc
@@ -29,7 +29,7 @@ const size_t count = 1000; // TODO: We may want to read this from argv.
 int main(int, const char**) {
 #ifdef BOOST_COROUTINES
     for (size_t i = 2; i < 5; ++i) { //fanout
-        for (size_t j = 1; j < 10; ++j) { // Number of workers
+        for (size_t j = 1; j <= 10; ++j) { // Number of workers
             cout << "Layered cache with " << j << " work processes and " <<
                 "fanout of " << i << endl;
             isc::resolver::bench::LayerResolver layer_resolver(::count, j, i);
@@ -37,7 +37,7 @@ int main(int, const char**) {
                 (1, layer_resolver, true);
         }
     }
-    for (size_t i = 1; i < 10; ++i) {
+    for (size_t i = 1; i <= 10; ++i) {
         cout << "Coroutine resolver with " << i << " threads" << endl;
         isc::resolver::bench::CoroutineResolver coroutine_resolver(::count, i);
         isc::bench::BenchMark<isc::resolver::bench::CoroutineResolver>



More information about the bind10-changes mailing list