Browse Source

Add CLOSE_MS and CLOSE_RATE keywords to buildtimeout event.

Mike Perry 15 years ago
parent
commit
2abe1ceccf
4 changed files with 30 additions and 4 deletions
  1. 6 2
      doc/spec/control-spec.txt
  2. 19 0
      src/or/circuitbuild.c
  3. 4 2
      src/or/control.c
  4. 1 0
      src/or/or.h

+ 6 - 2
doc/spec/control-spec.txt

@@ -1670,14 +1670,18 @@
   The syntax is:
   The syntax is:
      "650" SP "BUILDTIMEOUT_SET" SP Type SP "TOTAL_TIMES=" Total SP
      "650" SP "BUILDTIMEOUT_SET" SP Type SP "TOTAL_TIMES=" Total SP
         "TIMEOUT_MS=" Timeout SP "XM=" Xm SP "ALPHA=" Alpha SP
         "TIMEOUT_MS=" Timeout SP "XM=" Xm SP "ALPHA=" Alpha SP
-        "CUTOFF_QUANTILE=" Quantile SP "TIMEOUT_RATE=" Rate CRLF
+        "CUTOFF_QUANTILE=" Quantile SP "TIMEOUT_RATE=" TimeoutRate SP
+        "CLOSE_MS=" CloseTimeout SP "CLOSE_RATE=" CloseRate
+        CRLF
      Type = "COMPUTED" / "RESET" / "SUSPENDED" / "DISCARD" / "RESUME"
      Type = "COMPUTED" / "RESET" / "SUSPENDED" / "DISCARD" / "RESUME"
      Total = Integer count of timeouts stored
      Total = Integer count of timeouts stored
      Timeout = Integer timeout in milliseconds
      Timeout = Integer timeout in milliseconds
      Xm = Estimated integer Pareto parameter Xm in milliseconds
      Xm = Estimated integer Pareto parameter Xm in milliseconds
      Alpha = Estimated floating point Paredo paremter alpha
      Alpha = Estimated floating point Paredo paremter alpha
      Quantile = Floating point CDF quantile cutoff point for this timeout
      Quantile = Floating point CDF quantile cutoff point for this timeout
-     Rate = Floating point ratio of circuits that timeout
+     TimeoutRate = Floating point ratio of circuits that timeout
+     CloseTimeout = How long to keep measurement circs in milliseconds
+     CloseRate = Floating point ratio of measurement circuits that are closed
 
 
   A new circuit build timeout time has been set. If Type is "COMPUTED",
   A new circuit build timeout time has been set. If Type is "COMPUTED",
   Tor has computed the value based on historical data. If Type is "RESET",
   Tor has computed the value based on historical data. If Type is "RESET",

+ 19 - 0
src/or/circuitbuild.c

@@ -1088,6 +1088,25 @@ circuit_build_times_timeout_rate(const circuit_build_times_t *cbt)
   return ((double)timeouts)/cbt->total_build_times;
   return ((double)timeouts)/cbt->total_build_times;
 }
 }
 
 
+/**
+ * Count the number of closed circuits in a set of cbt data.
+ */
+double
+circuit_build_times_close_rate(const circuit_build_times_t *cbt)
+{
+  int i=0,closed=0;
+  for (i = 0; i < CBT_NCIRCUITS_TO_OBSERVE; i++) {
+    if (cbt->circuit_build_times[i] == CBT_BUILD_ABANDONED) {
+       closed++;
+    }
+  }
+
+  if (!cbt->total_build_times)
+    return 0;
+
+  return ((double)closed)/cbt->total_build_times;
+}
+
 /**
 /**
  * Store a timeout as a synthetic value.
  * Store a timeout as a synthetic value.
  *
  *

+ 4 - 2
src/or/control.c

@@ -3530,11 +3530,13 @@ control_event_buildtimeout_set(const circuit_build_times_t *cbt,
   send_control_event(EVENT_BUILDTIMEOUT_SET, ALL_FORMATS,
   send_control_event(EVENT_BUILDTIMEOUT_SET, ALL_FORMATS,
                      "650 BUILDTIMEOUT_SET %s TOTAL_TIMES=%lu "
                      "650 BUILDTIMEOUT_SET %s TOTAL_TIMES=%lu "
                      "TIMEOUT_MS=%lu XM=%lu ALPHA=%lf CUTOFF_QUANTILE=%lf "
                      "TIMEOUT_MS=%lu XM=%lu ALPHA=%lf CUTOFF_QUANTILE=%lf "
-                     "TIMEOUT_RATE=%lf\r\n",
+                     "TIMEOUT_RATE=%lf CLOSE_MS=%lu CLOSE_RATE=%lf\r\n",
                      type_string, (unsigned long)cbt->total_build_times,
                      type_string, (unsigned long)cbt->total_build_times,
                      (unsigned long)cbt->timeout_ms,
                      (unsigned long)cbt->timeout_ms,
                      (unsigned long)cbt->Xm, cbt->alpha, qnt,
                      (unsigned long)cbt->Xm, cbt->alpha, qnt,
-                     circuit_build_times_timeout_rate(cbt));
+                     circuit_build_times_timeout_rate(cbt),
+                     (unsigned long)cbt->close_ms,
+                     circuit_build_times_close_rate(cbt));
 
 
   return 0;
   return 0;
 }
 }

+ 1 - 0
src/or/or.h

@@ -3173,6 +3173,7 @@ void circuit_build_times_init(circuit_build_times_t *cbt);
 void circuit_build_times_new_consensus_params(circuit_build_times_t *cbt,
 void circuit_build_times_new_consensus_params(circuit_build_times_t *cbt,
                                               networkstatus_t *ns);
                                               networkstatus_t *ns);
 double circuit_build_times_timeout_rate(const circuit_build_times_t *cbt);
 double circuit_build_times_timeout_rate(const circuit_build_times_t *cbt);
+double circuit_build_times_close_rate(const circuit_build_times_t *cbt);
 
 
 #ifdef CIRCUIT_PRIVATE
 #ifdef CIRCUIT_PRIVATE
 double circuit_build_times_calculate_timeout(circuit_build_times_t *cbt,
 double circuit_build_times_calculate_timeout(circuit_build_times_t *cbt,