diff options
author | David Goulet <dgoulet@torproject.org> | 2022-12-05 13:23:34 -0500 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2022-12-05 13:23:34 -0500 |
commit | 2595913bd60d3a0cda9009c28239015f88da8efa (patch) | |
tree | fe81c84091a381eb8c399ba01ba17a8a1cebbb56 | |
parent | ba77ccae02177778e3d0d8d70a2c38077e3bd36c (diff) | |
parent | a51cd9a56971bbee67a3e0c1d34d56aa4689b3f1 (diff) | |
download | tor-2595913bd60d3a0cda9009c28239015f88da8efa.tar.gz tor-2595913bd60d3a0cda9009c28239015f88da8efa.zip |
Merge branch 'maint-0.4.7' into release-0.4.7
-rw-r--r-- | changes/ticket40724 | 3 | ||||
-rw-r--r-- | src/core/or/circuitlist.c | 3 | ||||
-rw-r--r-- | src/core/or/circuitlist.h | 1 | ||||
-rw-r--r-- | src/core/or/congestion_control_common.c | 5 | ||||
-rw-r--r-- | src/core/or/congestion_control_common.h | 2 | ||||
-rw-r--r-- | src/core/or/congestion_control_vegas.c | 99 | ||||
-rw-r--r-- | src/core/or/congestion_control_vegas.h | 13 | ||||
-rw-r--r-- | src/feature/relay/relay_metrics.c | 104 |
8 files changed, 221 insertions, 9 deletions
diff --git a/changes/ticket40724 b/changes/ticket40724 new file mode 100644 index 0000000000..aeb6f9ae8b --- /dev/null +++ b/changes/ticket40724 @@ -0,0 +1,3 @@ + o Minor feature (Congestion control metrics): + - Add additional metricsport relay metrics for congestion control. + Closes ticket 40724. 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 2b0ed3a507..54b89dad64 100644 --- a/src/core/or/congestion_control_vegas.c +++ b/src/core/or/congestion_control_vegas.c @@ -52,15 +52,26 @@ /** Moving average of the cc->cwnd from each circuit exiting slowstart. */ double cc_stats_vegas_exit_ss_cwnd_ma = 0; +double cc_stats_vegas_exit_ss_bdp_ma = 0; +double cc_stats_vegas_exit_ss_inc_ma = 0; double cc_stats_vegas_gamma_drop_ma = 0; double cc_stats_vegas_delta_drop_ma = 0; double cc_stats_vegas_ss_csig_blocked_ma = 0; double cc_stats_vegas_csig_blocked_ma = 0; +double cc_stats_vegas_csig_alpha_ma = 0; +double cc_stats_vegas_csig_beta_ma = 0; +double cc_stats_vegas_csig_delta_ma = 0; + +double cc_stats_vegas_ss_queue_ma = 0; +double cc_stats_vegas_queue_ma = 0; +double cc_stats_vegas_bdp_ma = 0; /** Stats on how many times we reached "delta" param. */ 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. @@ -256,10 +267,17 @@ 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); + cc_stats_vegas_exit_ss_bdp_ma = + stats_update_running_avg(cc_stats_vegas_exit_ss_bdp_ma, + vegas_bdp(cc)); + 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. */ @@ -327,32 +345,39 @@ congestion_control_vegas_process_sendme(congestion_control_t *cc, if (inc*SENDME_PER_CWND(cc) <= CWND_INC(cc)) { cc->cwnd += inc; congestion_control_vegas_exit_slow_start(circ, cc); + + cc_stats_vegas_below_ss_inc_floor++; + + /* We exited slow start without being blocked */ + cc_stats_vegas_ss_csig_blocked_ma = + stats_update_running_avg(cc_stats_vegas_ss_csig_blocked_ma, + 0); } else { cc->cwnd += inc; 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); - cc_stats_vegas_gamma_drop_ma = - stats_update_running_avg(cc_stats_vegas_gamma_drop_ma, - cwnd_diff); - /* Compute the percentage we experience a blocked csig vs RTT sig */ if (cc->blocked_chan) { cc_stats_vegas_ss_csig_blocked_ma = stats_update_running_avg(cc_stats_vegas_ss_csig_blocked_ma, 100); } else { + uint64_t cwnd_diff = (old_cwnd > cc->cwnd ? old_cwnd - cc->cwnd : 0); + cc_stats_vegas_ss_csig_blocked_ma = stats_update_running_avg(cc_stats_vegas_ss_csig_blocked_ma, 0); + + /* Account the amount we reduced the cwnd by for the gamma cutoff */ + cc_stats_vegas_gamma_drop_ma = + stats_update_running_avg(cc_stats_vegas_gamma_drop_ma, + cwnd_diff); } congestion_control_vegas_exit_slow_start(circ, cc); @@ -363,6 +388,10 @@ congestion_control_vegas_process_sendme(congestion_control_t *cc, congestion_control_vegas_exit_slow_start(circ, cc); cc_stats_vegas_above_ss_cwnd_max++; } + + cc_stats_vegas_ss_queue_ma = + stats_update_running_avg(cc_stats_vegas_ss_queue_ma, + queue_use); /* After slow start, We only update once per window */ } else if (cc->next_cc_event == 0) { if (queue_use > cc->vegas_params.delta) { @@ -380,7 +409,20 @@ congestion_control_vegas_process_sendme(congestion_control_t *cc, cwnd_diff); cc_stats_vegas_above_delta++; + + /* Percentage metrics: Add 100% delta, 0 for other two */ + cc_stats_vegas_csig_alpha_ma = + stats_update_running_avg(cc_stats_vegas_csig_alpha_ma, + 0); + cc_stats_vegas_csig_beta_ma = + stats_update_running_avg(cc_stats_vegas_csig_beta_ma, + 0); + cc_stats_vegas_csig_delta_ma = + stats_update_running_avg(cc_stats_vegas_csig_delta_ma, + 100); } else if (queue_use > cc->vegas_params.beta || cc->blocked_chan) { + cc->cwnd -= CWND_INC(cc); + /* Compute the percentage we experience a blocked csig vs RTT sig */ if (cc->blocked_chan) { cc_stats_vegas_csig_blocked_ma = @@ -392,9 +434,40 @@ congestion_control_vegas_process_sendme(congestion_control_t *cc, 0); } - cc->cwnd -= CWND_INC(cc); + /* Percentage counters: Add 100% beta, 0 for other two */ + cc_stats_vegas_csig_alpha_ma = + stats_update_running_avg(cc_stats_vegas_csig_alpha_ma, + 0); + cc_stats_vegas_csig_beta_ma = + stats_update_running_avg(cc_stats_vegas_csig_beta_ma, + 100); + cc_stats_vegas_csig_delta_ma = + stats_update_running_avg(cc_stats_vegas_csig_delta_ma, + 0); } else if (queue_use < cc->vegas_params.alpha) { cc->cwnd += CWND_INC(cc); + + /* Percentage counters: Add 100% alpha, 0 for other two */ + cc_stats_vegas_csig_alpha_ma = + stats_update_running_avg(cc_stats_vegas_csig_alpha_ma, + 100); + cc_stats_vegas_csig_beta_ma = + stats_update_running_avg(cc_stats_vegas_csig_beta_ma, + 0); + cc_stats_vegas_csig_delta_ma = + stats_update_running_avg(cc_stats_vegas_csig_delta_ma, + 0); + } else { + /* Percentage counters: No signal this round. Add 0% to all */ + cc_stats_vegas_csig_alpha_ma = + stats_update_running_avg(cc_stats_vegas_csig_alpha_ma, + 0); + cc_stats_vegas_csig_beta_ma = + stats_update_running_avg(cc_stats_vegas_csig_beta_ma, + 0); + cc_stats_vegas_csig_delta_ma = + stats_update_running_avg(cc_stats_vegas_csig_delta_ma, + 0); } /* cwnd can never fall below 1 increment */ @@ -405,6 +478,14 @@ congestion_control_vegas_process_sendme(congestion_control_t *cc, congestion_control_vegas_log(circ, cc); + /* Update metrics */ + cc_stats_vegas_queue_ma = + stats_update_running_avg(cc_stats_vegas_queue_ma, + queue_use); + cc_stats_vegas_bdp_ma = + stats_update_running_avg(cc_stats_vegas_bdp_ma, + vegas_bdp(cc)); + /* Log if we're above the ss_cap */ if (cc->cwnd >= cc->vegas_params.ss_cwnd_max) { log_info(LD_CIRC, diff --git a/src/core/or/congestion_control_vegas.h b/src/core/or/congestion_control_vegas.h index 722ffde01a..84070664c8 100644 --- a/src/core/or/congestion_control_vegas.h +++ b/src/core/or/congestion_control_vegas.h @@ -13,6 +13,8 @@ #include "core/or/circuit_st.h" extern double cc_stats_vegas_exit_ss_cwnd_ma; +extern double cc_stats_vegas_exit_ss_bdp_ma; +extern double cc_stats_vegas_exit_ss_inc_ma; extern double cc_stats_vegas_gamma_drop_ma; extern double cc_stats_vegas_delta_drop_ma; extern double cc_stats_vegas_ss_csig_blocked_ma; @@ -20,6 +22,17 @@ extern double cc_stats_vegas_csig_blocked_ma; extern uint64_t cc_stats_vegas_above_delta; extern uint64_t cc_stats_vegas_above_ss_cwnd_max; +extern double cc_stats_vegas_csig_alpha_ma; +extern double cc_stats_vegas_csig_beta_ma; +extern double cc_stats_vegas_csig_delta_ma; + +extern double cc_stats_vegas_ss_queue_ma; +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, const circuit_t *circ, diff --git a/src/feature/relay/relay_metrics.c b/src/feature/relay/relay_metrics.c index b2c53f389a..e18770b4e2 100644 --- a/src/feature/relay/relay_metrics.c +++ b/src/feature/relay/relay_metrics.c @@ -449,6 +449,38 @@ fill_cc_counters_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", "cc_limits")); + 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. */ @@ -470,6 +502,24 @@ fill_cc_gauges_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, + metrics_format_label("action", "bdp")); + metrics_store_entry_update(sentry, + tor_llround(cc_stats_vegas_exit_ss_bdp_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", "inc")); + metrics_store_entry_update(sentry, + tor_llround(cc_stats_vegas_exit_ss_inc_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", "cwnd")); @@ -538,6 +588,60 @@ fill_cc_gauges_values(void) metrics_format_label("action", "ss_chan_blocked_pct")); metrics_store_entry_update(sentry, tor_llround(cc_stats_vegas_ss_csig_blocked_ma)); + + sentry = metrics_store_add(the_store, rentry->type, rentry->name, + rentry->help); + metrics_store_entry_add_label(sentry, + metrics_format_label("state", "cc_cwnd_update")); + metrics_store_entry_add_label(sentry, + metrics_format_label("action", "alpha_pct")); + metrics_store_entry_update(sentry, + tor_llround(cc_stats_vegas_csig_alpha_ma)); + + sentry = metrics_store_add(the_store, rentry->type, rentry->name, + rentry->help); + metrics_store_entry_add_label(sentry, + metrics_format_label("state", "cc_cwnd_update")); + metrics_store_entry_add_label(sentry, + metrics_format_label("action", "beta_pct")); + metrics_store_entry_update(sentry, + tor_llround(cc_stats_vegas_csig_beta_ma)); + + sentry = metrics_store_add(the_store, rentry->type, rentry->name, + rentry->help); + metrics_store_entry_add_label(sentry, + metrics_format_label("state", "cc_cwnd_update")); + metrics_store_entry_add_label(sentry, + metrics_format_label("action", "delta_pct")); + metrics_store_entry_update(sentry, + tor_llround(cc_stats_vegas_csig_delta_ma)); + + sentry = metrics_store_add(the_store, rentry->type, rentry->name, + rentry->help); + metrics_store_entry_add_label(sentry, + metrics_format_label("state", "cc_estimates")); + metrics_store_entry_add_label(sentry, + metrics_format_label("action", "ss_queue")); + metrics_store_entry_update(sentry, + tor_llround(cc_stats_vegas_ss_queue_ma)); + + sentry = metrics_store_add(the_store, rentry->type, rentry->name, + rentry->help); + metrics_store_entry_add_label(sentry, + metrics_format_label("state", "cc_estimates")); + metrics_store_entry_add_label(sentry, + metrics_format_label("action", "queue")); + metrics_store_entry_update(sentry, + tor_llround(cc_stats_vegas_queue_ma)); + + sentry = metrics_store_add(the_store, rentry->type, rentry->name, + rentry->help); + metrics_store_entry_add_label(sentry, + metrics_format_label("state", "cc_estimates")); + metrics_store_entry_add_label(sentry, + metrics_format_label("action", "bdp")); + metrics_store_entry_update(sentry, + tor_llround(cc_stats_vegas_bdp_ma)); } /** Helper: Fill in single stream metrics output. */ |