aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Perry <mikeperry-git@torproject.org>2022-12-02 21:50:59 +0000
committerMike Perry <mikeperry-git@torproject.org>2022-12-02 21:50:59 +0000
commita51cd9a56971bbee67a3e0c1d34d56aa4689b3f1 (patch)
tree1720e354a8cdffea2e44f0c8e8bd7d6c9c323f47
parent4c419183cc4c414ad0ce300c9cd7f6d663106f37 (diff)
downloadtor-a51cd9a56971bbee67a3e0c1d34d56aa4689b3f1.tar.gz
tor-a51cd9a56971bbee67a3e0c1d34d56aa4689b3f1.zip
Ticket 40724: Add metrics for CC circuit counts
-rw-r--r--src/core/or/circuitlist.c3
-rw-r--r--src/core/or/circuitlist.h1
-rw-r--r--src/core/or/congestion_control_common.c5
-rw-r--r--src/core/or/congestion_control_common.h2
-rw-r--r--src/core/or/congestion_control_vegas.c4
-rw-r--r--src/core/or/congestion_control_vegas.h1
-rw-r--r--src/feature/relay/relay_metrics.c24
7 files changed, 39 insertions, 1 deletions
diff --git a/src/core/or/circuitlist.c b/src/core/or/circuitlist.c
index eb13e3bccd..50dc2ee338 100644
--- a/src/core/or/circuitlist.c
+++ b/src/core/or/circuitlist.c
@@ -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)
diff --git a/src/core/or/circuitlist.h b/src/core/or/circuitlist.h
index 281ea1f76f..541a708de2 100644
--- a/src/core/or/circuitlist.h
+++ b/src/core/or/circuitlist.h
@@ -164,6 +164,7 @@
/** 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. */
diff --git a/src/core/or/congestion_control_common.c b/src/core/or/congestion_control_common.c
index c27eb2fca8..e96d22cbfa 100644
--- a/src/core/or/congestion_control_common.c
+++ b/src/core/or/congestion_control_common.c
@@ -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;
}
diff --git a/src/core/or/congestion_control_common.h b/src/core/or/congestion_control_common.h
index a2740fb0b6..fa8f67bb8b 100644
--- a/src/core/or/congestion_control_common.h
+++ b/src/core/or/congestion_control_common.h
@@ -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;
diff --git a/src/core/or/congestion_control_vegas.c b/src/core/or/congestion_control_vegas.c
index b1a5a4d2a3..54b89dad64 100644
--- a/src/core/or/congestion_control_vegas.c
+++ b/src/core/or/congestion_control_vegas.c
@@ -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. */
diff --git a/src/core/or/congestion_control_vegas.h b/src/core/or/congestion_control_vegas.h
index b9f273a091..84070664c8 100644
--- a/src/core/or/congestion_control_vegas.h
+++ b/src/core/or/congestion_control_vegas.h
@@ -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,
diff --git a/src/feature/relay/relay_metrics.c b/src/feature/relay/relay_metrics.c
index f80efe17fe..e18770b4e2 100644
--- a/src/feature/relay/relay_metrics.c
+++ b/src/feature/relay/relay_metrics.c
@@ -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. */