]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Ticket 40724: Add metrics for CC circuit counts
authorMike Perry <mikeperry-git@torproject.org>
Fri, 2 Dec 2022 21:50:59 +0000 (21:50 +0000)
committerMike Perry <mikeperry-git@torproject.org>
Fri, 2 Dec 2022 21:50:59 +0000 (21:50 +0000)
src/core/or/circuitlist.c
src/core/or/circuitlist.h
src/core/or/congestion_control_common.c
src/core/or/congestion_control_common.h
src/core/or/congestion_control_vegas.c
src/core/or/congestion_control_vegas.h
src/feature/relay/relay_metrics.c

index eb13e3bccdb4425bec7907ce1077c3dd0401813b..50dc2ee3386d70b954f3dc59a2083c3152fbf724 100644 (file)
@@ -154,6 +154,8 @@ double cc_stats_circ_close_cwnd_ma = 0;
 /** Moving average of the cc->cwnd from each closed slow-start circuit. */
 double cc_stats_circ_close_ss_cwnd_ma = 0;
 
+uint64_t cc_stats_circs_closed = 0;
+
 /********* END VARIABLES ************/
 
 /* Implement circuit handle helpers. */
@@ -2249,6 +2251,7 @@ circuit_mark_for_close_, (circuit_t *circ, int reason, int line,
         stats_update_running_avg(cc_stats_circ_close_cwnd_ma,
                                  circ->ccontrol->cwnd);
     }
+    cc_stats_circs_closed++;
   }
 
   if (circuits_pending_close == NULL)
index 281ea1f76fef845aa9e2fe888b59e39eba7ea0be..541a708de2c243094c4e915e1da920b12c47f4c0 100644 (file)
 /** Stats. */
 extern double cc_stats_circ_close_cwnd_ma;
 extern double cc_stats_circ_close_ss_cwnd_ma;
+extern uint64_t cc_stats_circs_closed;
 
 /** Convert a circuit_t* to a pointer to the enclosing or_circuit_t.  Assert
  * if the cast is impossible. */
index c27eb2fca849a26f420a2be44d0508b5e5efd323..e96d22cbfaaf1e165a5c02019bdf6095b844eb4e 100644 (file)
@@ -132,6 +132,9 @@ static uint8_t bwe_sendme_min;
  */
 static uint8_t rtt_reset_pct;
 
+/** Metric to count the number of congestion control circuits **/
+uint64_t cc_stats_circs_created = 0;
+
 /** Return the number of RTT reset that have been done. */
 uint64_t
 congestion_control_get_num_rtt_reset(void)
@@ -422,6 +425,8 @@ congestion_control_new(const circuit_params_t *params, cc_path_t path)
 
   congestion_control_init(cc, params, path);
 
+  cc_stats_circs_created++;
+
   return cc;
 }
 
index a2740fb0b6cc1cf6342df0a74bba705dc0ab5150..fa8f67bb8bf92cfb520b058e205189f139a44557 100644 (file)
@@ -85,6 +85,8 @@ char *congestion_control_get_control_port_fields(const origin_circuit_t *);
 uint64_t congestion_control_get_num_rtt_reset(void);
 uint64_t congestion_control_get_num_clock_stalls(void);
 
+extern uint64_t cc_stats_circs_created;
+
 /* Ugh, C.. these are private. Use the getter instead, when
  * external to the congestion control code. */
 extern uint32_t or_conn_highwater;
index b1a5a4d2a3eb15d53bfc9ae3a7f56470e4424f9f..54b89dad643d8e0c3b7b932b40be292431ef7813 100644 (file)
@@ -71,6 +71,7 @@ uint64_t cc_stats_vegas_above_delta = 0;
 /** Stats on how many times we reached "ss_cwnd_max" param. */
 uint64_t cc_stats_vegas_above_ss_cwnd_max = 0;
 uint64_t cc_stats_vegas_below_ss_inc_floor = 0;
+uint64_t cc_stats_vegas_circ_exited_ss = 0;
 
 /**
  * The original TCP Vegas congestion window BDP estimator.
@@ -266,7 +267,7 @@ congestion_control_vegas_exit_slow_start(const circuit_t *circ,
   cc->next_cc_event = CWND_UPDATE_RATE(cc);
   congestion_control_vegas_log(circ, cc);
 
-  /* Update running cc->cwnd average for metrics. */
+  /* Update metricsport metrics */
   cc_stats_vegas_exit_ss_cwnd_ma =
     stats_update_running_avg(cc_stats_vegas_exit_ss_cwnd_ma,
                              cc->cwnd);
@@ -276,6 +277,7 @@ congestion_control_vegas_exit_slow_start(const circuit_t *circ,
   cc_stats_vegas_exit_ss_inc_ma =
     stats_update_running_avg(cc_stats_vegas_exit_ss_inc_ma,
                              rfc3742_ss_inc(cc));
+  cc_stats_vegas_circ_exited_ss++;
 
   /* We need to report that slow start has exited ASAP,
    * for sbws bandwidth measurement. */
index b9f273a091e99c85bca5f41680e3446606bc8071..84070664c88c2d36c639b21874aa48361f9c609a 100644 (file)
@@ -31,6 +31,7 @@ extern double cc_stats_vegas_queue_ma;
 extern double cc_stats_vegas_bdp_ma;
 
 extern uint64_t cc_stats_vegas_below_ss_inc_floor;
+extern uint64_t cc_stats_vegas_circ_exited_ss;
 
 /* Processing SENDME cell. */
 int congestion_control_vegas_process_sendme(struct congestion_control_t *cc,
index f80efe17feb8d2a58aa4f3c3d1c2137ff10a53c4..e18770b4e25e355d68972aa37649b288000aaaf0 100644 (file)
@@ -457,6 +457,30 @@ fill_cc_counters_values(void)
   metrics_store_entry_add_label(sentry,
           metrics_format_label("action", "below_ss_inc_floor"));
   metrics_store_entry_update(sentry, cc_stats_vegas_below_ss_inc_floor);
+
+  sentry = metrics_store_add(the_store, rentry->type, rentry->name,
+                             rentry->help);
+  metrics_store_entry_add_label(sentry,
+          metrics_format_label("state", "cc_circuits"));
+  metrics_store_entry_add_label(sentry,
+          metrics_format_label("action", "circs_creared"));
+  metrics_store_entry_update(sentry, cc_stats_circs_created);
+
+  sentry = metrics_store_add(the_store, rentry->type, rentry->name,
+                             rentry->help);
+  metrics_store_entry_add_label(sentry,
+          metrics_format_label("state", "cc_circuits"));
+  metrics_store_entry_add_label(sentry,
+          metrics_format_label("action", "circs_closed"));
+  metrics_store_entry_update(sentry, cc_stats_circs_closed);
+
+  sentry = metrics_store_add(the_store, rentry->type, rentry->name,
+                             rentry->help);
+  metrics_store_entry_add_label(sentry,
+          metrics_format_label("state", "cc_circuits"));
+  metrics_store_entry_add_label(sentry,
+          metrics_format_label("action", "circs_exited_ss"));
+  metrics_store_entry_update(sentry, cc_stats_vegas_circ_exited_ss);
 }
 
 /** Fill function for the RELAY_METRICS_CC_GAUGES metric. */