Browse Source

r15868@catbus: nickm | 2007-10-16 14:18:29 -0400
Remove nearly all calls to routerlist_remove_old(). Backport candidate.


svn:r11994

Nick Mathewson 16 years ago
parent
commit
9d7eba6ecc
3 changed files with 19 additions and 6 deletions
  1. 4 0
      ChangeLog
  2. 2 1
      src/or/main.c
  3. 13 5
      src/or/routerlist.c

+ 4 - 0
ChangeLog

@@ -16,6 +16,10 @@ Changes in version 0.2.0.9-alpha - 2007-10-??
       than 28 days unmodified, then most likely it's a leftover from when we
       upgraded to 0.2.0.8-alpha.  Remove it.  It has no good routers anyway.
 
+  o Minor features (performance):
+    - Call routerlist_remove_old_routers() much less often.  This should
+      speed startup, especially on directory caches.
+
   o Minor bugfixes (directory authorities):
     - Correct the implementation of "download votes by digest."  Bugfix on
       0.2.0.8-alpha.

+ 2 - 1
src/or/main.c

@@ -994,8 +994,9 @@ run_scheduled_events(time_t now)
     /* If any networkstatus documents are no longer recent, we need to
      * update all the descriptors' running status. */
     /* purge obsolete entries */
-    routerlist_remove_old_routers();
     networkstatus_v2_list_clean(now);
+    /* Remove dead routers. */
+    routerlist_remove_old_routers();
 #if 0
     networkstatus_v2_list_update_recent(now);
 #endif

+ 13 - 5
src/or/routerlist.c

@@ -475,7 +475,7 @@ router_rebuild_store(int force, desc_store_t *store)
   if (!routerlist)
     return 0;
 
-  routerlist_assert_ok(routerlist);
+  //routerlist_assert_ok(routerlist);
 
   /* Don't save deadweight. */
   routerlist_remove_old_routers();
@@ -2140,6 +2140,7 @@ dump_routerlist_mem_usage(int severity)
       smartlist_len(routerlist->old_routers), U64_PRINTF_ARG(olddescs));
 }
 
+#if 0
 /** Return non-zero if we have a lot of extra descriptors in our
  * routerlist, and should get rid of some of them. Else return 0.
  *
@@ -2158,6 +2159,7 @@ routerlist_is_overfull(routerlist_t *rl)
     return smartlist_len(rl->old_routers) > smartlist_len(rl->routers)*2;
   }
 }
+#endif
 
 static INLINE int
 _routerlist_find_elt(smartlist_t *sl, void *ri, int idx)
@@ -2613,8 +2615,10 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
     return -1;
   }
 
+#if 0
   if (routerlist_is_overfull(routerlist))
     routerlist_remove_old_routers();
+#endif
 
   if (authdir) {
     if (authdir_wants_to_reject_router(router, msg,
@@ -2907,7 +2911,7 @@ routerlist_remove_old_routers(void)
   if (!routerlist || !consensus)
     return;
 
-  routerlist_assert_ok(routerlist);
+  // routerlist_assert_ok(routerlist);
 
   retain = digestmap_new();
   cutoff = now - OLD_ROUTER_DESC_MAX_AGE;
@@ -2959,7 +2963,7 @@ routerlist_remove_old_routers(void)
     }
   }
 
-  routerlist_assert_ok(routerlist);
+  //routerlist_assert_ok(routerlist);
 
   /* Remove far-too-old members of routerlist->old_routers. */
   cutoff = now - OLD_ROUTER_DESC_MAX_AGE;
@@ -2972,7 +2976,7 @@ routerlist_remove_old_routers(void)
     }
   }
 
-  routerlist_assert_ok(routerlist);
+  //routerlist_assert_ok(routerlist);
 
   /* Now we might have to look at routerlist->old_routers for extraneous
    * members. (We'd keep all the members if we could, but we need to save
@@ -3002,7 +3006,7 @@ routerlist_remove_old_routers(void)
   }
   if (hi>=0)
     routerlist_remove_old_cached_routers_with_id(cutoff, 0, hi, retain);
-  routerlist_assert_ok(routerlist);
+  //routerlist_assert_ok(routerlist);
 
  done:
   digestmap_free(retain, NULL);
@@ -3477,6 +3481,10 @@ client_would_use_router(routerstatus_t *rs, time_t now, or_options_t *options)
     /* Most caches probably don't have this descriptor yet. */
     return 0;
   }
+  if (rs->published_on + OLD_ROUTER_DESC_MAX_AGE < now) {
+    /* We'd drop it immediately for being too old. */
+    return 0;
+  }
   return 1;
 }