[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor] 02/15: metrics: Add running average of CC cwnd when exiting slow start
This is an automated email from the git hooks/post-receive script.
dgoulet pushed a commit to branch main
in repository tor.
commit c565ef9c58546a815431d575c9ad16fb0bf2dc22
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
AuthorDate: Thu Nov 3 10:43:37 2022 -0400
metrics: Add running average of CC cwnd when exiting slow start
Part of #40708
Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
src/core/or/congestion_control_vegas.c | 11 +++++++++++
src/core/or/congestion_control_vegas.h | 2 ++
src/feature/relay/relay_metrics.c | 16 ++++++++++++++--
src/lib/math/include.am | 3 ++-
src/lib/math/stats.h | 19 +++++++++++++++++++
5 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/src/core/or/congestion_control_vegas.c b/src/core/or/congestion_control_vegas.c
index f129ecadd6..de89f294aa 100644
--- a/src/core/or/congestion_control_vegas.c
+++ b/src/core/or/congestion_control_vegas.c
@@ -23,6 +23,7 @@
#include "core/or/channel.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/control/control_events.h"
+#include "lib/math/stats.h"
#define OUTBUF_CELLS (2*TLS_RECORD_MAX_CELLS)
@@ -49,6 +50,11 @@
#define VEGAS_DELTA_ONION_DFLT (9*OUTBUF_CELLS)
#define VEGAS_SSCAP_ONION_DFLT (600)
+/** Moving average of the cc->cwnd from each circuit exiting slowstart. */
+double cc_stats_vegas_exit_ss_cwnd_ma = 0;
+/* Running count of this moving average. Needed so we can update it. */
+static double stats_cwnd_exit_ss_ma_count = 0;
+
/**
* The original TCP Vegas congestion window BDP estimator.
*/
@@ -243,6 +249,11 @@ 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. */
+ stats_cwnd_exit_ss_ma_count++;
+ STATS_UPDATE_AVG(cc_stats_vegas_exit_ss_cwnd_ma,
+ cc->cwnd, stats_cwnd_exit_ss_ma_count);
+
/* We need to report that slow start has exited ASAP,
* for sbws bandwidth measurement. */
if (CIRCUIT_IS_ORIGIN(circ)) {
diff --git a/src/core/or/congestion_control_vegas.h b/src/core/or/congestion_control_vegas.h
index 95fcea5722..71f0ea571d 100644
--- a/src/core/or/congestion_control_vegas.h
+++ b/src/core/or/congestion_control_vegas.h
@@ -12,6 +12,8 @@
#include "core/or/crypt_path_st.h"
#include "core/or/circuit_st.h"
+extern double cc_stats_vegas_exit_ss_cwnd_ma;
+
/* 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 c7f6fe8846..1bfbfbd898 100644
--- a/src/feature/relay/relay_metrics.c
+++ b/src/feature/relay/relay_metrics.c
@@ -14,16 +14,18 @@
#include "core/mainloop/connection.h"
#include "core/mainloop/mainloop.h"
#include "core/or/congestion_control_common.h"
+#include "core/or/congestion_control_vegas.h"
#include "core/or/circuitlist.h"
#include "core/or/dos.h"
#include "core/or/relay.h"
#include "app/config/config.h"
-#include "lib/malloc/malloc.h"
#include "lib/container/smartlist.h"
-#include "lib/metrics/metrics_store.h"
#include "lib/log/util_bug.h"
+#include "lib/malloc/malloc.h"
+#include "lib/math/fp.h"
+#include "lib/metrics/metrics_store.h"
#include "feature/hs/hs_dos.h"
#include "feature/nodelist/nodelist.h"
@@ -370,6 +372,16 @@ fill_cc_values(void)
metrics_store_entry_add_label(sentry,
metrics_format_label("action", "rtt_reset"));
metrics_store_entry_update(sentry, congestion_control_get_num_rtt_reset());
+
+ 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", "cwnd"));
+ metrics_store_entry_update(sentry,
+ tor_llround(cc_stats_vegas_exit_ss_cwnd_ma));
}
/** Helper: Fill in single stream metrics output. */
diff --git a/src/lib/math/include.am b/src/lib/math/include.am
index b2ca280f47..f68b265da7 100644
--- a/src/lib/math/include.am
+++ b/src/lib/math/include.am
@@ -20,4 +20,5 @@ src_lib_libtor_math_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
noinst_HEADERS += \
src/lib/math/fp.h \
src/lib/math/laplace.h \
- src/lib/math/prob_distr.h
+ src/lib/math/prob_distr.h \
+ src/lib/math/stats.h
diff --git a/src/lib/math/stats.h b/src/lib/math/stats.h
new file mode 100644
index 0000000000..fae93c6213
--- /dev/null
+++ b/src/lib/math/stats.h
@@ -0,0 +1,19 @@
+/* Copyright (c) 2022, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file stats.h
+ *
+ * \brief Header for stats.c
+ **/
+
+#ifndef TOR_STATS_H
+#define TOR_STATS_H
+
+/** Update an average making it a "running average". The "avg" is the current
+ * value that will be updated to the new one. The "value" is the new value to
+ * add to the average and "n" is the new count as in including the "value". */
+#define STATS_UPDATE_AVG(avg, value, n) \
+ avg = ((avg) * ((n) - 1) + (value)) / (n)
+
+#endif /* !defined(TOR_STATS_H) */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits