mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
parent
2f7e05d89d
commit
fec9757a37
@ -23,6 +23,7 @@
|
||||
#include "feature/nodelist/networkstatus.h"
|
||||
#include "trunnel/flow_control_cells.h"
|
||||
#include "feature/control/control_events.h"
|
||||
#include "lib/math/stats.h"
|
||||
|
||||
#include "core/or/connection_st.h"
|
||||
#include "core/or/cell_st.h"
|
||||
@ -36,6 +37,14 @@ static uint32_t xon_change_pct;
|
||||
static uint32_t xon_ewma_cnt;
|
||||
static uint32_t xon_rate_bytes;
|
||||
|
||||
/** Metricsport stats */
|
||||
uint64_t cc_stats_flow_num_xoff_sent;
|
||||
uint64_t cc_stats_flow_num_xon_sent;
|
||||
double cc_stats_flow_xoff_outbuf_ma = 0;
|
||||
static double cc_stats_flow_xoff_outbuf_ma_count = 0;
|
||||
double cc_stats_flow_xon_outbuf_ma = 0;
|
||||
static double cc_stats_flow_xon_outbuf_ma_count = 0;
|
||||
|
||||
/* In normal operation, we can get a burst of up to 32 cells before returning
|
||||
* to libevent to flush the outbuf. This is a heuristic from hardcoded values
|
||||
* and strange logic in connection_bucket_get_share(). */
|
||||
@ -148,6 +157,7 @@ circuit_send_stream_xoff(edge_connection_t *stream)
|
||||
if (connection_edge_send_command(stream, RELAY_COMMAND_XOFF,
|
||||
(char*)payload, (size_t)xoff_size) == 0) {
|
||||
stream->xoff_sent = true;
|
||||
cc_stats_flow_num_xoff_sent++;
|
||||
|
||||
/* If this is an entry conn, notify control port */
|
||||
if (TO_CONN(stream)->type == CONN_TYPE_AP) {
|
||||
@ -222,6 +232,8 @@ circuit_send_stream_xon(edge_connection_t *stream)
|
||||
/* Revert the xoff sent status, so we can send another one if need be */
|
||||
stream->xoff_sent = false;
|
||||
|
||||
cc_stats_flow_num_xon_sent++;
|
||||
|
||||
/* If it's an entry conn, notify control port */
|
||||
if (TO_CONN(stream)->type == CONN_TYPE_AP) {
|
||||
control_event_stream_status(TO_ENTRY_CONN(TO_CONN(stream)),
|
||||
@ -473,6 +485,10 @@ flow_control_decide_xoff(edge_connection_t *stream)
|
||||
total_buffered, buffer_limit_xoff);
|
||||
tor_trace(TR_SUBSYS(cc), TR_EV(flow_decide_xoff_sending), stream);
|
||||
|
||||
cc_stats_flow_xoff_outbuf_ma_count++;
|
||||
STATS_UPDATE_AVG(cc_stats_flow_xoff_outbuf_ma,
|
||||
total_buffered, cc_stats_flow_xoff_outbuf_ma_count);
|
||||
|
||||
circuit_send_stream_xoff(stream);
|
||||
|
||||
/* Clear the drain rate. It is considered wrong if we
|
||||
@ -627,6 +643,11 @@ flow_control_decide_xon(edge_connection_t *stream, size_t n_written)
|
||||
stream->ewma_drain_rate,
|
||||
total_buffered);
|
||||
tor_trace(TR_SUBSYS(cc), TR_EV(flow_decide_xon_rate_change), stream);
|
||||
|
||||
cc_stats_flow_xon_outbuf_ma_count++;
|
||||
STATS_UPDATE_AVG(cc_stats_flow_xon_outbuf_ma,
|
||||
total_buffered, cc_stats_flow_xon_outbuf_ma_count);
|
||||
|
||||
circuit_send_stream_xon(stream);
|
||||
}
|
||||
} else if (total_buffered == 0) {
|
||||
|
@ -33,6 +33,12 @@ bool conn_uses_flow_control(connection_t *stream);
|
||||
|
||||
uint64_t edge_get_max_rtt(const edge_connection_t *);
|
||||
|
||||
/** Metricsport externs */
|
||||
extern uint64_t cc_stats_flow_num_xoff_sent;
|
||||
extern uint64_t cc_stats_flow_num_xon_sent;
|
||||
extern double cc_stats_flow_xoff_outbuf_ma;
|
||||
extern double cc_stats_flow_xon_outbuf_ma;
|
||||
|
||||
/* Private section starts. */
|
||||
#ifdef TOR_CONGESTION_CONTROL_FLOW_PRIVATE
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "core/mainloop/mainloop.h"
|
||||
#include "core/or/congestion_control_common.h"
|
||||
#include "core/or/congestion_control_vegas.h"
|
||||
#include "core/or/congestion_control_flow.h"
|
||||
#include "core/or/circuitlist.h"
|
||||
#include "core/or/dos.h"
|
||||
#include "core/or/relay.h"
|
||||
@ -409,6 +410,42 @@ fill_cc_values(void)
|
||||
metrics_store_entry_update(sentry,
|
||||
tor_llround(cc_stats_circ_close_ss_cwnd_ma));
|
||||
|
||||
sentry = metrics_store_add(the_store, rentry->type, rentry->name,
|
||||
rentry->help);
|
||||
metrics_store_entry_add_label(sentry,
|
||||
metrics_format_label("state", "xoff"));
|
||||
metrics_store_entry_add_label(sentry,
|
||||
metrics_format_label("action", "outbuf"));
|
||||
metrics_store_entry_update(sentry,
|
||||
tor_llround(cc_stats_flow_xoff_outbuf_ma));
|
||||
|
||||
sentry = metrics_store_add(the_store, rentry->type, rentry->name,
|
||||
rentry->help);
|
||||
metrics_store_entry_add_label(sentry,
|
||||
metrics_format_label("state", "xoff"));
|
||||
metrics_store_entry_add_label(sentry,
|
||||
metrics_format_label("action", "num_sent"));
|
||||
metrics_store_entry_update(sentry,
|
||||
cc_stats_flow_num_xoff_sent);
|
||||
|
||||
sentry = metrics_store_add(the_store, rentry->type, rentry->name,
|
||||
rentry->help);
|
||||
metrics_store_entry_add_label(sentry,
|
||||
metrics_format_label("state", "xon"));
|
||||
metrics_store_entry_add_label(sentry,
|
||||
metrics_format_label("action", "outbuf"));
|
||||
metrics_store_entry_update(sentry,
|
||||
tor_llround(cc_stats_flow_xon_outbuf_ma));
|
||||
|
||||
sentry = metrics_store_add(the_store, rentry->type, rentry->name,
|
||||
rentry->help);
|
||||
metrics_store_entry_add_label(sentry,
|
||||
metrics_format_label("state", "xon"));
|
||||
metrics_store_entry_add_label(sentry,
|
||||
metrics_format_label("action", "num_sent"));
|
||||
metrics_store_entry_update(sentry,
|
||||
cc_stats_flow_num_xon_sent);
|
||||
|
||||
sentry = metrics_store_add(the_store, rentry->type, rentry->name,
|
||||
rentry->help);
|
||||
metrics_store_entry_add_label(sentry,
|
||||
|
Loading…
Reference in New Issue
Block a user