diff options
author | David Goulet <dgoulet@torproject.org> | 2022-11-03 12:41:21 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2022-11-07 09:55:06 -0500 |
commit | a0e72fcb976e38de20bf53629c96a489dc626096 (patch) | |
tree | 0a6ea5a886eaca2a4e7de1d85088327a1b759d83 /src/core | |
parent | c565ef9c58546a815431d575c9ad16fb0bf2dc22 (diff) | |
download | tor-a0e72fcb976e38de20bf53629c96a489dc626096.tar.gz tor-a0e72fcb976e38de20bf53629c96a489dc626096.zip |
metrics: Add running average of CC cwnd when closing circuit
Part of #40708
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/or/circuitlist.c | 14 | ||||
-rw-r--r-- | src/core/or/circuitlist.h | 3 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/core/or/circuitlist.c b/src/core/or/circuitlist.c index 4dbf4d4549..b21d95ade7 100644 --- a/src/core/or/circuitlist.c +++ b/src/core/or/circuitlist.c @@ -102,6 +102,8 @@ #include "lib/compress/compress_zstd.h" #include "lib/buf/buffers.h" #include "core/or/congestion_control_common.h" +#include "core/or/congestion_control_st.h" +#include "lib/math/stats.h" #include "core/or/ocirc_event.h" @@ -147,6 +149,11 @@ static void circuit_about_to_free(circuit_t *circ); */ static int any_opened_circs_cached_val = 0; +/** Moving average of the cc->cwnd from each closed circuit. */ +double cc_stats_circ_close_cwnd_ma = 0; +/* Running count of this moving average. Needed so we can update it. */ +static double stats_circ_close_cwnd_ma_count = 0; + /********* END VARIABLES ************/ /* Implement circuit handle helpers. */ @@ -2225,6 +2232,13 @@ circuit_mark_for_close_, (circuit_t *circ, int reason, int line, /* Notify the HS subsystem that this circuit is closing. */ hs_circ_cleanup_on_close(circ); + /* Update stats. */ + if (circ->ccontrol) { + stats_circ_close_cwnd_ma_count++; + STATS_UPDATE_AVG(cc_stats_circ_close_cwnd_ma, + circ->ccontrol->cwnd, stats_circ_close_cwnd_ma_count); + } + if (circuits_pending_close == NULL) circuits_pending_close = smartlist_new(); diff --git a/src/core/or/circuitlist.h b/src/core/or/circuitlist.h index 147e2cb2f8..1a99083bc6 100644 --- a/src/core/or/circuitlist.h +++ b/src/core/or/circuitlist.h @@ -161,6 +161,9 @@ ((p) == CIRCUIT_PURPOSE_C_GENERAL || \ (p) == CIRCUIT_PURPOSE_C_HSDIR_GET) +/** Stats. */ +extern double cc_stats_circ_close_cwnd_ma; + /** Convert a circuit_t* to a pointer to the enclosing or_circuit_t. Assert * if the cast is impossible. */ or_circuit_t *TO_OR_CIRCUIT(circuit_t *); |