diff options
author | Mike Perry <mikeperry-git@torproject.org> | 2022-12-01 22:18:02 +0000 |
---|---|---|
committer | Mike Perry <mikeperry-git@torproject.org> | 2022-12-01 22:19:08 +0000 |
commit | 07b521560fb740f2227c67195f89c04b2d0a30d8 (patch) | |
tree | 7b68504aae26264ff004fcc2610278d04ff1d54b | |
parent | a91bcb5516640104e3b1dfa3502bc408e0506152 (diff) | |
download | tor-07b521560fb740f2227c67195f89c04b2d0a30d8.tar.gz tor-07b521560fb740f2227c67195f89c04b2d0a30d8.zip |
Ticket 40724: Additional congestion control metrics
-rw-r--r-- | src/core/or/congestion_control_vegas.c | 95 | ||||
-rw-r--r-- | src/core/or/congestion_control_vegas.h | 12 | ||||
-rw-r--r-- | src/feature/relay/relay_metrics.c | 80 |
3 files changed, 179 insertions, 8 deletions
diff --git a/src/core/or/congestion_control_vegas.c b/src/core/or/congestion_control_vegas.c index 2b0ed3a507..b1a5a4d2a3 100644 --- a/src/core/or/congestion_control_vegas.c +++ b/src/core/or/congestion_control_vegas.c @@ -52,15 +52,25 @@ /** 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; /** * The original TCP Vegas congestion window BDP estimator. @@ -260,6 +270,12 @@ congestion_control_vegas_exit_slow_start(const circuit_t *circ, 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)); /* We need to report that slow start has exited ASAP, * for sbws bandwidth measurement. */ @@ -327,32 +343,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 +386,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 +407,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 +432,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 +476,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..b9f273a091 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,16 @@ 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; + /* 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..f80efe17fe 100644 --- a/src/feature/relay/relay_metrics.c +++ b/src/feature/relay/relay_metrics.c @@ -449,6 +449,14 @@ 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); } /** Fill function for the RELAY_METRICS_CC_GAUGES metric. */ @@ -470,6 +478,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 +564,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. */ |