[tor-commits] [tor] 06/15: metrics: Add running average of CC cwnd in slow start when closing circuit

gitolite role git at cupani.torproject.org
Tue Nov 8 17:49:42 UTC 2022


This is an automated email from the git hooks/post-receive script.

dgoulet pushed a commit to branch main
in repository tor.

commit 83fdaff7c0920c8943b483e4146d2762b8e6ca94
Author: Mike Perry <mikeperry-git at torproject.org>
AuthorDate: Thu Nov 3 19:48:16 2022 +0000

    metrics: Add running average of CC cwnd in slow start when closing circuit
    
    Count slow start separately.
    
    Part of #40708
    
    Signed-off-by: David Goulet <dgoulet at torproject.org>
---
 src/core/or/circuitlist.c         | 24 ++++++++++++++++++++----
 src/core/or/circuitlist.h         |  1 +
 src/feature/relay/relay_metrics.c | 11 +++++++++--
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/src/core/or/circuitlist.c b/src/core/or/circuitlist.c
index b21d95ade7..ddcb9bebe4 100644
--- a/src/core/or/circuitlist.c
+++ b/src/core/or/circuitlist.c
@@ -151,8 +151,12 @@ static int any_opened_circs_cached_val = 0;
 
 /** Moving average of the cc->cwnd from each closed circuit. */
 double cc_stats_circ_close_cwnd_ma = 0;
-/* Running count of this moving average. Needed so we can update it. */
+/** Moving average of the cc->cwnd from each closed slow-start circuit. */
+double cc_stats_circ_close_ss_cwnd_ma = 0;
+
+/* Running count of the above moving averages. Needed so we can update it. */
 static double stats_circ_close_cwnd_ma_count = 0;
+static double stats_circ_close_ss_cwnd_ma_count = 0;
 
 /********* END VARIABLES ************/
 
@@ -2234,9 +2238,21 @@ circuit_mark_for_close_, (circuit_t *circ, int reason, int line,
 
   /* Update stats. */
   if (circ->ccontrol) {
-    stats_circ_close_cwnd_ma_count++;
-    STATS_UPDATE_AVG(cc_stats_circ_close_cwnd_ma,
-                     circ->ccontrol->cwnd, stats_circ_close_cwnd_ma_count);
+    if (circ->ccontrol->in_slow_start) {
+      /* If we are in slow start, only count the ss cwnd if we've sent
+       * enough data to get RTT measurements such that we have a min
+       * and a max RTT, and they are not the same. This prevents us from
+       * averaging and reporting unused and low-use circuits here */
+      if (circ->ccontrol->max_rtt_usec != circ->ccontrol->min_rtt_usec) {
+        stats_circ_close_ss_cwnd_ma_count++;
+        STATS_UPDATE_AVG(cc_stats_circ_close_ss_cwnd_ma,
+                   circ->ccontrol->cwnd, stats_circ_close_ss_cwnd_ma_count);
+      }
+    } else {
+      stats_circ_close_cwnd_ma_count++;
+      STATS_UPDATE_AVG(cc_stats_circ_close_cwnd_ma,
+                       circ->ccontrol->cwnd, stats_circ_close_cwnd_ma_count);
+    }
   }
 
   if (circuits_pending_close == NULL)
diff --git a/src/core/or/circuitlist.h b/src/core/or/circuitlist.h
index 1a99083bc6..281ea1f76f 100644
--- a/src/core/or/circuitlist.h
+++ b/src/core/or/circuitlist.h
@@ -163,6 +163,7 @@
 
 /** Stats. */
 extern double cc_stats_circ_close_cwnd_ma;
+extern double cc_stats_circ_close_ss_cwnd_ma;
 
 /** Convert a circuit_t* to a pointer to the enclosing or_circuit_t.  Assert
  * if the cast is impossible. */
diff --git a/src/feature/relay/relay_metrics.c b/src/feature/relay/relay_metrics.c
index b95ca4ba06..9ceb61836e 100644
--- a/src/feature/relay/relay_metrics.c
+++ b/src/feature/relay/relay_metrics.c
@@ -375,7 +375,6 @@ fill_cc_values(void)
 
   sentry = metrics_store_add(the_store, rentry->type, rentry->name,
                              rentry->help);
-
   metrics_store_entry_add_label(sentry,
           metrics_format_label("state", "slow_start_exit"));
   metrics_store_entry_add_label(sentry,
@@ -385,7 +384,6 @@ fill_cc_values(void)
 
   sentry = metrics_store_add(the_store, rentry->type, rentry->name,
                              rentry->help);
-
   metrics_store_entry_add_label(sentry,
           metrics_format_label("state", "on_circ_close"));
   metrics_store_entry_add_label(sentry,
@@ -393,6 +391,15 @@ fill_cc_values(void)
   metrics_store_entry_update(sentry,
                              tor_llround(cc_stats_circ_close_cwnd_ma));
 
+  sentry = metrics_store_add(the_store, rentry->type, rentry->name,
+                             rentry->help);
+  metrics_store_entry_add_label(sentry,
+          metrics_format_label("state", "on_circ_close"));
+  metrics_store_entry_add_label(sentry,
+          metrics_format_label("action", "ss_cwnd"));
+  metrics_store_entry_update(sentry,
+                             tor_llround(cc_stats_circ_close_ss_cwnd_ma));
+
   sentry = metrics_store_add(the_store, rentry->type, rentry->name,
                              rentry->help);
   metrics_store_entry_add_label(sentry,

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list