This is an automated email from the git hooks/post-receive script.
dgoulet pushed a change to branch main in repository tor.
from 5f548f05d2 Merge branch 'tor-gitlab/mr/585' new 98b98fd3ce rephist: Track number of streams seen per type new e7e18ae914 relay: Add total number of streams seen on MetricsPort new 00f714b374 relay: Add CC RTT reset stats to MetricsPort new 06a26f1872 relay: Change the connection metrics name new a1c40c8511 metrics: Fix naming and documentation new fff2b92682 Merge branch 'maint-0.4.7'
The 6 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
Summary of changes: src/core/or/congestion_control_common.c | 11 ++++++ src/core/or/congestion_control_common.h | 2 ++ src/core/or/connection_edge.c | 10 ++++++ src/core/or/relay.c | 2 +- src/core/or/relay.h | 2 ++ src/feature/relay/relay_metrics.c | 64 +++++++++++++++++++++++++++++++-- src/feature/relay/relay_metrics.h | 4 +++ src/feature/stats/rephist.c | 45 +++++++++++++++++++++++ src/feature/stats/rephist.h | 3 ++ 9 files changed, 140 insertions(+), 3 deletions(-)
This is an automated email from the git hooks/post-receive script.
dgoulet pushed a commit to branch main in repository tor.
commit 98b98fd3ce767d9fd303908337fdae0a4d558d67 Author: David Goulet dgoulet@torproject.org AuthorDate: Thu Oct 13 10:32:16 2022 -0400
rephist: Track number of streams seen per type
Related to #40194
Signed-off-by: David Goulet dgoulet@torproject.org --- src/core/or/connection_edge.c | 10 ++++++++++ src/feature/stats/rephist.c | 44 +++++++++++++++++++++++++++++++++++++++++++ src/feature/stats/rephist.h | 3 +++ 3 files changed, 57 insertions(+)
diff --git a/src/core/or/connection_edge.c b/src/core/or/connection_edge.c index 7ba7ecc4c5..2a79d0cf58 100644 --- a/src/core/or/connection_edge.c +++ b/src/core/or/connection_edge.c @@ -4119,6 +4119,9 @@ connection_exit_begin_resolve(cell_t *cell, or_circuit_t *circ) if (rh.length > RELAY_PAYLOAD_SIZE) return -1;
+ /* Note the RESOLVE stream as seen. */ + rep_hist_note_stream(RELAY_COMMAND_RESOLVE); + /* This 'dummy_conn' only exists to remember the stream ID * associated with the resolve request; and to make the * implementation of dns.c more uniform. (We really only need to @@ -4241,6 +4244,10 @@ connection_exit_connect(edge_connection_t *edge_conn) return; }
+ /* Note the BEGIN stream as seen. We do this after the Exit policy check in + * order to only account for valid streams. */ + rep_hist_note_stream(RELAY_COMMAND_BEGIN); + #ifdef HAVE_SYS_UN_H if (conn->socket_family != AF_UNIX) { #else @@ -4336,6 +4343,9 @@ connection_exit_connect_dir(edge_connection_t *exitconn)
log_info(LD_EXIT, "Opening local connection for anonymized directory exit");
+ /* Note the BEGIN_DIR stream as seen. */ + rep_hist_note_stream(RELAY_COMMAND_BEGIN_DIR); + exitconn->base_.state = EXIT_CONN_STATE_OPEN;
dirconn = dir_connection_new(tor_addr_family(&exitconn->base_.addr)); diff --git a/src/feature/stats/rephist.c b/src/feature/stats/rephist.c index f12b1e8a70..962450e72b 100644 --- a/src/feature/stats/rephist.c +++ b/src/feature/stats/rephist.c @@ -1639,6 +1639,50 @@ rep_hist_note_exit_stream_opened(uint16_t port) log_debug(LD_HIST, "Opened exit stream to port %d", port); }
+/*** Streams statistics ***/ + +/** Number of BEGIN streams seen. */ +static uint64_t streams_begin_seen; +/** Number of BEGIN_DIR streams seen. */ +static uint64_t streams_begindir_seen; +/** Number of RESOLVE streams seen. */ +static uint64_t streams_resolve_seen; + +/** Note a stream as seen for the given relay command. */ +void +rep_hist_note_stream(unsigned int cmd) +{ + switch (cmd) { + case RELAY_COMMAND_BEGIN: + streams_begin_seen++; + break; + case RELAY_COMMAND_BEGIN_DIR: + streams_begindir_seen++; + break; + case RELAY_COMMAND_RESOLVE: + streams_resolve_seen++; + break; + default: + break; + } +} + +/** Return number of stream seen for the given command. */ +uint64_t +rep_hist_get_stream_seen(unsigned int cmd) +{ + switch (cmd) { + case RELAY_COMMAND_BEGIN: + return streams_begin_seen; + case RELAY_COMMAND_BEGIN_DIR: + return streams_begindir_seen; + case RELAY_COMMAND_RESOLVE: + return streams_resolve_seen; + default: + return 0; + } +} + /******* Connections statistics *******/
#define CONN_DIRECTION_INITIATED 0 diff --git a/src/feature/stats/rephist.h b/src/feature/stats/rephist.h index 2a83dd185e..c1352ae7f8 100644 --- a/src/feature/stats/rephist.h +++ b/src/feature/stats/rephist.h @@ -48,6 +48,9 @@ uint64_t rep_hist_get_conn_created(bool initiated, unsigned int type); uint64_t rep_hist_get_conn_opened(bool initiated, unsigned int type); uint64_t rep_hist_get_conn_rejected(unsigned int type);
+void rep_hist_note_stream(unsigned int cmd); +uint64_t rep_hist_get_stream_seen(unsigned int cmd); + void rep_hist_buffer_stats_init(time_t now); void rep_hist_buffer_stats_add_circ(circuit_t *circ, time_t end_of_interval);
This is an automated email from the git hooks/post-receive script.
dgoulet pushed a commit to branch main in repository tor.
commit e7e18ae914871c6135355f4037b541ed7398fa3d Author: David Goulet dgoulet@torproject.org AuthorDate: Thu Oct 13 10:41:21 2022 -0400
relay: Add total number of streams seen on MetricsPort
Related to #40194
Signed-off-by: David Goulet dgoulet@torproject.org --- src/core/or/relay.c | 2 +- src/core/or/relay.h | 2 ++ src/feature/relay/relay_metrics.c | 36 ++++++++++++++++++++++++++++++++++++ src/feature/relay/relay_metrics.h | 2 ++ 4 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/src/core/or/relay.c b/src/core/or/relay.c index 01a377b6f5..d77c47100a 100644 --- a/src/core/or/relay.c +++ b/src/core/or/relay.c @@ -502,7 +502,7 @@ relay_header_unpack(relay_header_t *dest, const uint8_t *src) }
/** Convert the relay <b>command</b> into a human-readable string. */ -static const char * +const char * relay_command_to_string(uint8_t command) { static char buf[64]; diff --git a/src/core/or/relay.h b/src/core/or/relay.h index 71e07562cd..24466bccd0 100644 --- a/src/core/or/relay.h +++ b/src/core/or/relay.h @@ -16,6 +16,8 @@ extern uint64_t stats_n_relay_cells_relayed; extern uint64_t stats_n_relay_cells_delivered; extern uint64_t stats_n_circ_max_cell_reached;
+const char *relay_command_to_string(uint8_t command); + void relay_consensus_has_changed(const networkstatus_t *ns); uint32_t relay_get_param_max_circuit_cell_queue_size( const networkstatus_t *ns); diff --git a/src/feature/relay/relay_metrics.c b/src/feature/relay/relay_metrics.c index 8d0fef86b3..e48e211ba7 100644 --- a/src/feature/relay/relay_metrics.c +++ b/src/feature/relay/relay_metrics.c @@ -32,6 +32,7 @@ static void fill_global_bw_limit_values(void); static void fill_socket_values(void); static void fill_onionskins_values(void); static void fill_oom_values(void); +static void fill_streams_values(void); static void fill_tcp_exhaustion_values(void);
/** The base metrics that is a static array of metrics added to the metrics @@ -96,6 +97,13 @@ static const relay_metrics_entry_t base_metrics[] = .help = "Connections metrics of this relay", .fill_fn = fill_connections_values, }, + { + .key = RELAY_METRICS_NUM_STREAMS, + .type = METRICS_TYPE_COUNTER, + .name = METRICS_NAME(relay_streams_total), + .help = "Total number of streams", + .fill_fn = fill_streams_values, + }, }; static const size_t num_base_metrics = ARRAY_LENGTH(base_metrics);
@@ -122,6 +130,34 @@ handshake_type_to_str(const uint16_t type) } }
+/** Helper: Fill in single stream metrics output. */ +static void +fill_single_stream_value(metrics_store_entry_t *sentry, uint8_t cmd) +{ + metrics_store_entry_add_label(sentry, + metrics_format_label("type", relay_command_to_string(cmd))); + metrics_store_entry_update(sentry, rep_hist_get_stream_seen(cmd)); +} + +/** Fill function for the RELAY_METRICS_NUM_STREAMS metric. */ +static void +fill_streams_values(void) +{ + const relay_metrics_entry_t *rentry = + &base_metrics[RELAY_METRICS_NUM_STREAMS]; + metrics_store_entry_t *sentry = + metrics_store_add(the_store, rentry->type, rentry->name, rentry->help); + fill_single_stream_value(sentry, RELAY_COMMAND_BEGIN); + + sentry = metrics_store_add(the_store, rentry->type, rentry->name, + rentry->help); + fill_single_stream_value(sentry, RELAY_COMMAND_BEGIN_DIR); + + sentry = metrics_store_add(the_store, rentry->type, rentry->name, + rentry->help); + fill_single_stream_value(sentry, RELAY_COMMAND_RESOLVE); +} + /** Helper: Fill in single connection metrics output. */ static void fill_single_connection_value(metrics_store_entry_t *sentry, diff --git a/src/feature/relay/relay_metrics.h b/src/feature/relay/relay_metrics.h index 02b92cd043..17f9c9f195 100644 --- a/src/feature/relay/relay_metrics.h +++ b/src/feature/relay/relay_metrics.h @@ -31,6 +31,8 @@ typedef enum { RELAY_METRICS_NUM_TCP_EXHAUSTION = 6, /** Number of connections. */ RELAY_METRICS_NUM_CONNECTIONS = 7, + /** Number of streams. */ + RELAY_METRICS_NUM_STREAMS = 8, } relay_metrics_key_t;
/** The metadata of a relay metric. */
This is an automated email from the git hooks/post-receive script.
dgoulet pushed a commit to branch main in repository tor.
commit 00f714b37408381206af02951758b2505aabee1f Author: David Goulet dgoulet@torproject.org AuthorDate: Thu Oct 13 10:50:18 2022 -0400
relay: Add CC RTT reset stats to MetricsPort
Related to #40194
Signed-off-by: David Goulet dgoulet@torproject.org --- src/core/or/congestion_control_common.c | 11 +++++++++++ src/core/or/congestion_control_common.h | 2 ++ src/feature/relay/relay_metrics.c | 24 ++++++++++++++++++++++++ src/feature/relay/relay_metrics.h | 2 ++ 4 files changed, 39 insertions(+)
diff --git a/src/core/or/congestion_control_common.c b/src/core/or/congestion_control_common.c index 55be5d733b..09d1d501da 100644 --- a/src/core/or/congestion_control_common.c +++ b/src/core/or/congestion_control_common.c @@ -91,6 +91,9 @@ static bool congestion_control_update_circuit_bdp(congestion_control_t *, /* For unit tests */ void congestion_control_set_cc_enabled(void);
+/* Number of times the RTT value was reset. For MetricsPort. */ +static uint64_t num_rtt_reset; + /* Consensus parameters cached. The non static ones are extern. */ static uint32_t cwnd_max = CWND_MAX_DFLT; int32_t cell_queue_high = CELL_QUEUE_HIGH_DFLT; @@ -126,6 +129,13 @@ static uint8_t bwe_sendme_min; */ static uint8_t rtt_reset_pct;
+/** Return the number of RTT reset that have been done. */ +uint64_t +congestion_control_get_num_rtt_reset(void) +{ + return num_rtt_reset; +} + /** * Update global congestion control related consensus parameter values, * every consensus update. @@ -888,6 +898,7 @@ congestion_control_update_circuit_rtt(congestion_control_t *cc, cc->min_rtt_usec/1000, new_rtt/1000);
cc->min_rtt_usec = new_rtt; + num_rtt_reset++; /* Accounting */ } else if (cc->ewma_rtt_usec < cc->min_rtt_usec) { // Using the EWMA for min instead of current RTT helps average out // effects from other conns diff --git a/src/core/or/congestion_control_common.h b/src/core/or/congestion_control_common.h index 50af945d62..e62775ecce 100644 --- a/src/core/or/congestion_control_common.h +++ b/src/core/or/congestion_control_common.h @@ -82,6 +82,8 @@ int congestion_control_parse_ext_response(const uint8_t *msg, bool congestion_control_validate_sendme_increment(uint8_t sendme_inc); char *congestion_control_get_control_port_fields(const origin_circuit_t *);
+uint64_t congestion_control_get_num_rtt_reset(void); + /* 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/feature/relay/relay_metrics.c b/src/feature/relay/relay_metrics.c index e48e211ba7..77ccaac722 100644 --- a/src/feature/relay/relay_metrics.c +++ b/src/feature/relay/relay_metrics.c @@ -12,6 +12,7 @@
#include "core/or/or.h" #include "core/mainloop/connection.h" +#include "core/or/congestion_control_common.h" #include "core/or/relay.h"
#include "lib/malloc/malloc.h" @@ -25,6 +26,7 @@ #include <event2/dns.h>
/** Declarations of each fill function for metrics defined in base_metrics. */ +static void fill_cc_values(void); static void fill_connections_values(void); static void fill_dns_error_values(void); static void fill_dns_query_values(void); @@ -104,6 +106,13 @@ static const relay_metrics_entry_t base_metrics[] = .help = "Total number of streams", .fill_fn = fill_streams_values, }, + { + .key = RELAY_METRICS_NUM_CC, + .type = METRICS_TYPE_COUNTER, + .name = METRICS_NAME(relay_congestion_control_total), + .help = "Congestion control related counters", + .fill_fn = fill_cc_values, + }, }; static const size_t num_base_metrics = ARRAY_LENGTH(base_metrics);
@@ -130,6 +139,21 @@ handshake_type_to_str(const uint16_t type) } }
+/** Fill function for the RELAY_METRICS_NUM_CC metric. */ +static void +fill_cc_values(void) +{ + const relay_metrics_entry_t *rentry = &base_metrics[RELAY_METRICS_NUM_CC]; + metrics_store_entry_t *sentry = + metrics_store_add(the_store, rentry->type, rentry->name, rentry->help); + + metrics_store_entry_add_label(sentry, + metrics_format_label("state", "starvation")); + metrics_store_entry_add_label(sentry, + metrics_format_label("action", "rtt_reset")); + metrics_store_entry_update(sentry, congestion_control_get_num_rtt_reset()); +} + /** Helper: Fill in single stream metrics output. */ static void fill_single_stream_value(metrics_store_entry_t *sentry, uint8_t cmd) diff --git a/src/feature/relay/relay_metrics.h b/src/feature/relay/relay_metrics.h index 17f9c9f195..a594726668 100644 --- a/src/feature/relay/relay_metrics.h +++ b/src/feature/relay/relay_metrics.h @@ -33,6 +33,8 @@ typedef enum { RELAY_METRICS_NUM_CONNECTIONS = 7, /** Number of streams. */ RELAY_METRICS_NUM_STREAMS = 8, + /** Congestion control counters. */ + RELAY_METRICS_NUM_CC = 9, } relay_metrics_key_t;
/** The metadata of a relay metric. */
This is an automated email from the git hooks/post-receive script.
dgoulet pushed a commit to branch main in repository tor.
commit 06a26f18727d3831339c138ccec07ea2f7935014 Author: David Goulet dgoulet@torproject.org AuthorDate: Thu Oct 13 11:09:40 2022 -0400
relay: Change the connection metrics name
Signed-off-by: David Goulet dgoulet@torproject.org --- src/feature/relay/relay_metrics.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/feature/relay/relay_metrics.c b/src/feature/relay/relay_metrics.c index 77ccaac722..beae0e3f2f 100644 --- a/src/feature/relay/relay_metrics.c +++ b/src/feature/relay/relay_metrics.c @@ -95,8 +95,8 @@ static const relay_metrics_entry_t base_metrics[] = { .key = RELAY_METRICS_NUM_CONNECTIONS, .type = METRICS_TYPE_COUNTER, - .name = METRICS_NAME(relay_connections), - .help = "Connections metrics of this relay", + .name = METRICS_NAME(relay_connections_total), + .help = "Total number of connections", .fill_fn = fill_connections_values, }, {
This is an automated email from the git hooks/post-receive script.
dgoulet pushed a commit to branch main in repository tor.
commit a1c40c8511b841db773e82bd8024ef3581262900 Author: David Goulet dgoulet@torproject.org AuthorDate: Thu Oct 27 10:45:08 2022 -0400
metrics: Fix naming and documentation
After nickm's review, minor changes to names and comments.
Related to #40194
Signed-off-by: David Goulet dgoulet@torproject.org --- src/core/or/connection_edge.c | 6 +++--- src/feature/relay/relay_metrics.c | 2 +- src/feature/stats/rephist.c | 7 ++++--- src/feature/stats/rephist.h | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/core/or/connection_edge.c b/src/core/or/connection_edge.c index 2a79d0cf58..5ef7a0982b 100644 --- a/src/core/or/connection_edge.c +++ b/src/core/or/connection_edge.c @@ -4120,7 +4120,7 @@ connection_exit_begin_resolve(cell_t *cell, or_circuit_t *circ) return -1;
/* Note the RESOLVE stream as seen. */ - rep_hist_note_stream(RELAY_COMMAND_RESOLVE); + rep_hist_note_exit_stream(RELAY_COMMAND_RESOLVE);
/* This 'dummy_conn' only exists to remember the stream ID * associated with the resolve request; and to make the @@ -4246,7 +4246,7 @@ connection_exit_connect(edge_connection_t *edge_conn)
/* Note the BEGIN stream as seen. We do this after the Exit policy check in * order to only account for valid streams. */ - rep_hist_note_stream(RELAY_COMMAND_BEGIN); + rep_hist_note_exit_stream(RELAY_COMMAND_BEGIN);
#ifdef HAVE_SYS_UN_H if (conn->socket_family != AF_UNIX) { @@ -4344,7 +4344,7 @@ connection_exit_connect_dir(edge_connection_t *exitconn) log_info(LD_EXIT, "Opening local connection for anonymized directory exit");
/* Note the BEGIN_DIR stream as seen. */ - rep_hist_note_stream(RELAY_COMMAND_BEGIN_DIR); + rep_hist_note_exit_stream(RELAY_COMMAND_BEGIN_DIR);
exitconn->base_.state = EXIT_CONN_STATE_OPEN;
diff --git a/src/feature/relay/relay_metrics.c b/src/feature/relay/relay_metrics.c index beae0e3f2f..814afa6006 100644 --- a/src/feature/relay/relay_metrics.c +++ b/src/feature/relay/relay_metrics.c @@ -160,7 +160,7 @@ fill_single_stream_value(metrics_store_entry_t *sentry, uint8_t cmd) { metrics_store_entry_add_label(sentry, metrics_format_label("type", relay_command_to_string(cmd))); - metrics_store_entry_update(sentry, rep_hist_get_stream_seen(cmd)); + metrics_store_entry_update(sentry, rep_hist_get_exit_stream_seen(cmd)); }
/** Fill function for the RELAY_METRICS_NUM_STREAMS metric. */ diff --git a/src/feature/stats/rephist.c b/src/feature/stats/rephist.c index 962450e72b..021ef6d96e 100644 --- a/src/feature/stats/rephist.c +++ b/src/feature/stats/rephist.c @@ -1639,7 +1639,7 @@ rep_hist_note_exit_stream_opened(uint16_t port) log_debug(LD_HIST, "Opened exit stream to port %d", port); }
-/*** Streams statistics ***/ +/*** Exit streams statistics ***/
/** Number of BEGIN streams seen. */ static uint64_t streams_begin_seen; @@ -1650,7 +1650,7 @@ static uint64_t streams_resolve_seen;
/** Note a stream as seen for the given relay command. */ void -rep_hist_note_stream(unsigned int cmd) +rep_hist_note_exit_stream(unsigned int cmd) { switch (cmd) { case RELAY_COMMAND_BEGIN: @@ -1663,13 +1663,14 @@ rep_hist_note_stream(unsigned int cmd) streams_resolve_seen++; break; default: + tor_assert_nonfatal_unreached_once(); break; } }
/** Return number of stream seen for the given command. */ uint64_t -rep_hist_get_stream_seen(unsigned int cmd) +rep_hist_get_exit_stream_seen(unsigned int cmd) { switch (cmd) { case RELAY_COMMAND_BEGIN: diff --git a/src/feature/stats/rephist.h b/src/feature/stats/rephist.h index c1352ae7f8..02d23a4c1b 100644 --- a/src/feature/stats/rephist.h +++ b/src/feature/stats/rephist.h @@ -48,8 +48,8 @@ uint64_t rep_hist_get_conn_created(bool initiated, unsigned int type); uint64_t rep_hist_get_conn_opened(bool initiated, unsigned int type); uint64_t rep_hist_get_conn_rejected(unsigned int type);
-void rep_hist_note_stream(unsigned int cmd); -uint64_t rep_hist_get_stream_seen(unsigned int cmd); +void rep_hist_note_exit_stream(unsigned int cmd); +uint64_t rep_hist_get_exit_stream_seen(unsigned int cmd);
void rep_hist_buffer_stats_init(time_t now); void rep_hist_buffer_stats_add_circ(circuit_t *circ,
This is an automated email from the git hooks/post-receive script.
dgoulet pushed a commit to branch main in repository tor.
commit fff2b92682222c960e2cd4455e8264bcd5d406fb Merge: 5f548f05d2 a1c40c8511 Author: David Goulet dgoulet@torproject.org AuthorDate: Thu Oct 27 10:46:54 2022 -0400
Merge branch 'maint-0.4.7'
src/core/or/congestion_control_common.c | 11 ++++++ src/core/or/congestion_control_common.h | 2 ++ src/core/or/connection_edge.c | 10 ++++++ src/core/or/relay.c | 2 +- src/core/or/relay.h | 2 ++ src/feature/relay/relay_metrics.c | 64 +++++++++++++++++++++++++++++++-- src/feature/relay/relay_metrics.h | 4 +++ src/feature/stats/rephist.c | 45 +++++++++++++++++++++++ src/feature/stats/rephist.h | 3 ++ 9 files changed, 140 insertions(+), 3 deletions(-)
tor-commits@lists.torproject.org