mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
relay: Add CC RTT reset stats to MetricsPort
Related to #40194 Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
parent
e7e18ae914
commit
00f714b374
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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. */
|
||||
|
Loading…
Reference in New Issue
Block a user