Part of #40708.
#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"
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(). */
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) {
/* 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)),
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
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) {
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
#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"
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,