[tor-commits] [tor/master] Speed up hidden service bootstrap by reducing the initial post delay

nickm at torproject.org nickm at torproject.org
Sun Jan 11 16:12:10 UTC 2015


commit ac2f90ed001f168459afce8d137fe5e43baa173f
Author: teor <teor2345 at gmail.com>
Date:   Sat Jan 10 22:20:29 2015 +1100

    Speed up hidden service bootstrap by reducing the initial post delay
    
    Drop the MIN_REND_INITIAL_POST_DELAY on a testing network to 5 seconds,
    but keep the default at 30 seconds.
    
    Reduces the hidden service bootstrap to 25 seconds from around 45 seconds.
    Change the default src/test/test-network.sh delay to 25 seconds.
    
    Closes ticket 13401.
---
 changes/bug13401         |    7 +++++--
 src/or/rendservice.c     |   18 ++++++++++++------
 src/test/test-network.sh |    2 +-
 3 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/changes/bug13401 b/changes/bug13401
index 44be085..e2834a0 100644
--- a/changes/bug13401
+++ b/changes/bug13401
@@ -1,4 +1,7 @@
   o Minor features (testing networks):
     - Drop the minimum RendPostPeriod on a testing network to 5 seconds,
-      and the default to 2 minutes. Closes ticket 13401.
-
+      and the default to 2 minutes. Closes ticket 13401. Patch by "nickm".
+    - Drop the MIN_REND_INITIAL_POST_DELAY on a testing network to 5 seconds,
+      but keep the default at 30 seconds. This reduces HS bootstrap time to
+      around 25 seconds. Change src/test/test-network.sh default time to match.
+      Closes ticket 13401. Patch by "teor".
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 3b73674..ca9b380 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -3270,6 +3270,9 @@ rend_services_introduce(void)
   smartlist_free(exclude_nodes);
 }
 
+#define MIN_REND_INITIAL_POST_DELAY (30)
+#define MIN_REND_INITIAL_POST_DELAY_TESTING (5)
+
 /** Regenerate and upload rendezvous service descriptors for all
  * services, if necessary. If the descriptor has been dirty enough
  * for long enough, definitely upload; else only upload when the
@@ -3284,6 +3287,9 @@ rend_consider_services_upload(time_t now)
   int i;
   rend_service_t *service;
   int rendpostperiod = get_options()->RendPostPeriod;
+  int rendinitialpostdelay = (get_options()->TestingTorNetwork ?
+                              MIN_REND_INITIAL_POST_DELAY_TESTING :
+                              MIN_REND_INITIAL_POST_DELAY);
 
   if (!get_options()->PublishHidServDescriptors)
     return;
@@ -3291,17 +3297,17 @@ rend_consider_services_upload(time_t now)
   for (i=0; i < smartlist_len(rend_service_list); ++i) {
     service = smartlist_get(rend_service_list, i);
     if (!service->next_upload_time) { /* never been uploaded yet */
-      /* The fixed lower bound of 30 seconds ensures that the descriptor
-       * is stable before being published. See comment below. */
+      /* The fixed lower bound of rendinitialpostdelay seconds ensures that
+       * the descriptor is stable before being published. See comment below. */
       service->next_upload_time =
-        now + 30 + crypto_rand_int(2*rendpostperiod);
+        now + rendinitialpostdelay + crypto_rand_int(2*rendpostperiod);
     }
     if (service->next_upload_time < now ||
         (service->desc_is_dirty &&
-         service->desc_is_dirty < now-30)) {
+         service->desc_is_dirty < now-rendinitialpostdelay)) {
       /* if it's time, or if the directory servers have a wrong service
-       * descriptor and ours has been stable for 30 seconds, upload a
-       * new one of each format. */
+       * descriptor and ours has been stable for rendinitialpostdelay seconds,
+       * upload a new one of each format. */
       rend_service_update_descriptor(service);
       upload_service_descriptor(service);
     }
diff --git a/src/test/test-network.sh b/src/test/test-network.sh
index d28fbde..be57caf 100755
--- a/src/test/test-network.sh
+++ b/src/test/test-network.sh
@@ -45,7 +45,7 @@ PATH="$TOR_DIR/src/or:$TOR_DIR/src/tools:$PATH"
 
 # Sleep some, waiting for the network to bootstrap.
 # TODO: Add chutney command 'bootstrap-status' and use that instead.
-BOOTSTRAP_TIME=${BOOTSTRAP_TIME:-18}
+BOOTSTRAP_TIME=${BOOTSTRAP_TIME:-25}
 $ECHO_N "$myname: sleeping for $BOOTSTRAP_TIME seconds"
 n=$BOOTSTRAP_TIME; while [ $n -gt 0 ]; do
     sleep 1; n=$(expr $n - 1); $ECHO_N .





More information about the tor-commits mailing list