]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
metrics: Report amount of cwnd drop from delta and gamma
authorMike Perry <mikeperry-git@torproject.org>
Tue, 8 Nov 2022 17:39:34 +0000 (17:39 +0000)
committerDavid Goulet <dgoulet@torproject.org>
Tue, 8 Nov 2022 17:47:14 +0000 (12:47 -0500)
Part of #40708.

src/core/or/congestion_control_vegas.c
src/core/or/congestion_control_vegas.h
src/feature/relay/relay_metrics.c

index 87f59d12fd6885626b516abb40dae20fc92d485e..8351aa6e2754e76d09a0ac3676d4415e82a59622 100644 (file)
 
 /** Moving average of the cc->cwnd from each circuit exiting slowstart. */
 double cc_stats_vegas_exit_ss_cwnd_ma = 0;
+double cc_stats_vegas_gamma_drop_ma = 0;
+double cc_stats_vegas_delta_drop_ma = 0;
 /* Running count of this moving average. Needed so we can update it. */
 static double stats_cwnd_exit_ss_ma_count = 0;
+static double stats_cwnd_gamma_drop_ma_count = 0;
+static double stats_cwnd_delta_drop_ma_count = 0;
 
 /** Stats on how many times we reached "delta" param. */
 uint64_t cc_stats_vegas_above_delta = 0;
@@ -331,8 +335,19 @@ congestion_control_vegas_process_sendme(congestion_control_t *cc,
         cc->next_cc_event = 1; // Technically irellevant, but for consistency
       }
     } else {
+      uint64_t old_cwnd = cc->cwnd;
+      uint64_t cwnd_diff;
+
       /* Congestion signal: Set cwnd to gamma threshhold */
       cc->cwnd = vegas_bdp(cc) + cc->vegas_params.gamma;
+
+      /* Account the amount we reduced the cwnd by for the gamma cutoff */
+      cwnd_diff = (old_cwnd > cc->cwnd ? old_cwnd - cc->cwnd : 0);
+      stats_cwnd_gamma_drop_ma_count++;
+      cc_stats_vegas_gamma_drop_ma =
+        stats_update_running_avg(cc_stats_vegas_gamma_drop_ma,
+                             cwnd_diff, stats_cwnd_gamma_drop_ma_count);
+
       congestion_control_vegas_exit_slow_start(circ, cc);
     }
 
@@ -344,7 +359,20 @@ congestion_control_vegas_process_sendme(congestion_control_t *cc,
   /* After slow start, We only update once per window */
   } else if (cc->next_cc_event == 0) {
     if (queue_use > cc->vegas_params.delta) {
+      uint64_t old_cwnd = cc->cwnd;
+      uint64_t cwnd_diff;
+
+      /* If we are above the delta threshhold, drop cwnd down to the
+       * delta threshhold. */
       cc->cwnd = vegas_bdp(cc) + cc->vegas_params.delta - CWND_INC(cc);
+
+      /* Account the amount we reduced the cwnd by for the gamma cutoff */
+      cwnd_diff = (old_cwnd > cc->cwnd ? old_cwnd - cc->cwnd : 0);
+      stats_cwnd_delta_drop_ma_count++;
+      cc_stats_vegas_delta_drop_ma =
+        stats_update_running_avg(cc_stats_vegas_delta_drop_ma,
+                             cwnd_diff, stats_cwnd_delta_drop_ma_count);
+
       cc_stats_vegas_above_delta++;
     } else if (queue_use > cc->vegas_params.beta || cc->blocked_chan) {
       cc->cwnd -= CWND_INC(cc);
index 5aced07a8fb0875ec2db1cc45e51b0e735a69e78..6048b1e26d4ee19022595c97ccee582ed918269e 100644 (file)
@@ -13,6 +13,8 @@
 #include "core/or/circuit_st.h"
 
 extern double cc_stats_vegas_exit_ss_cwnd_ma;
+extern double cc_stats_vegas_gamma_drop_ma;
+extern double cc_stats_vegas_delta_drop_ma;
 extern uint64_t cc_stats_vegas_above_delta;
 extern uint64_t cc_stats_vegas_above_ss_cwnd_max;
 
index 076ac6861837236cf4ef9950b7e02bee31a744f2..cd80c5e95ea122db8026e0dff590c8d7febda9a6 100644 (file)
@@ -392,6 +392,15 @@ fill_cc_values(void)
   metrics_store_entry_update(sentry,
                              tor_llround(cc_stats_vegas_exit_ss_cwnd_ma));
 
+  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,
+          metrics_format_label("action", "gamma_drop"));
+  metrics_store_entry_update(sentry,
+                             tor_llround(cc_stats_vegas_gamma_drop_ma));
+
   sentry = metrics_store_add(the_store, rentry->type, rentry->name,
                              rentry->help);
   metrics_store_entry_add_label(sentry,
@@ -461,6 +470,15 @@ fill_cc_values(void)
   metrics_store_entry_add_label(sentry,
           metrics_format_label("action", "above_ss_cwnd_max"));
   metrics_store_entry_update(sentry, cc_stats_vegas_above_ss_cwnd_max);
+
+  sentry = metrics_store_add(the_store, rentry->type, rentry->name,
+                             rentry->help);
+  metrics_store_entry_add_label(sentry,
+          metrics_format_label("state", "process_sendme"));
+  metrics_store_entry_add_label(sentry,
+          metrics_format_label("action", "delta_drop"));
+  metrics_store_entry_update(sentry,
+                             tor_llround(cc_stats_vegas_delta_drop_ma));
 }
 
 /** Helper: Fill in single stream metrics output. */