mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Turn orconn watermarks into consensus parameters.
Tuning these may reduce memory usage and latency.
This commit is contained in:
parent
98be8634fa
commit
6dae9903b1
@ -27,6 +27,7 @@
|
|||||||
#include "core/or/channel.h"
|
#include "core/or/channel.h"
|
||||||
#include "core/or/channelpadding.h"
|
#include "core/or/channelpadding.h"
|
||||||
#include "core/or/circuitpadding.h"
|
#include "core/or/circuitpadding.h"
|
||||||
|
#include "core/or/congestion_control_common.h"
|
||||||
#include "core/or/congestion_control_flow.h"
|
#include "core/or/congestion_control_flow.h"
|
||||||
#include "core/or/circuitlist.h"
|
#include "core/or/circuitlist.h"
|
||||||
#include "core/or/command.h"
|
#include "core/or/command.h"
|
||||||
@ -631,6 +632,7 @@ tor_init(int argc, char *argv[])
|
|||||||
* until we get a consensus */
|
* until we get a consensus */
|
||||||
channelpadding_new_consensus_params(NULL);
|
channelpadding_new_consensus_params(NULL);
|
||||||
circpad_new_consensus_params(NULL);
|
circpad_new_consensus_params(NULL);
|
||||||
|
congestion_control_new_consensus_params(NULL);
|
||||||
flow_control_new_consensus_params(NULL);
|
flow_control_new_consensus_params(NULL);
|
||||||
|
|
||||||
/* Initialize circuit padding to defaults+torrc until we get a consensus */
|
/* Initialize circuit padding to defaults+torrc until we get a consensus */
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
#include "trunnel/netinfo.h"
|
#include "trunnel/netinfo.h"
|
||||||
#include "core/or/channelpadding.h"
|
#include "core/or/channelpadding.h"
|
||||||
#include "core/or/extendinfo.h"
|
#include "core/or/extendinfo.h"
|
||||||
|
#include "core/or/congestion_control_common.h"
|
||||||
|
|
||||||
#include "core/or/cell_st.h"
|
#include "core/or/cell_st.h"
|
||||||
#include "core/or/cell_queue_st.h"
|
#include "core/or/cell_queue_st.h"
|
||||||
@ -793,7 +794,7 @@ channel_tls_num_cells_writeable_method(channel_t *chan)
|
|||||||
cell_network_size = get_cell_network_size(tlschan->conn->wide_circ_ids);
|
cell_network_size = get_cell_network_size(tlschan->conn->wide_circ_ids);
|
||||||
outbuf_len = connection_get_outbuf_len(TO_CONN(tlschan->conn));
|
outbuf_len = connection_get_outbuf_len(TO_CONN(tlschan->conn));
|
||||||
/* Get the number of cells */
|
/* Get the number of cells */
|
||||||
n = CEIL_DIV(OR_CONN_HIGHWATER - outbuf_len, cell_network_size);
|
n = CEIL_DIV(or_conn_highwatermark() - outbuf_len, cell_network_size);
|
||||||
if (n < 0) n = 0;
|
if (n < 0) n = 0;
|
||||||
#if SIZEOF_SIZE_T > SIZEOF_INT
|
#if SIZEOF_SIZE_T > SIZEOF_INT
|
||||||
if (n > INT_MAX) n = INT_MAX;
|
if (n > INT_MAX) n = INT_MAX;
|
||||||
|
@ -46,6 +46,9 @@
|
|||||||
|
|
||||||
#define BWE_SENDME_MIN_DFLT 5
|
#define BWE_SENDME_MIN_DFLT 5
|
||||||
|
|
||||||
|
#define OR_CONN_HIGHWATER_DFLT (32*1024)
|
||||||
|
#define OR_CONN_LOWWATER_DFLT (16*1024)
|
||||||
|
|
||||||
static uint64_t congestion_control_update_circuit_rtt(congestion_control_t *,
|
static uint64_t congestion_control_update_circuit_rtt(congestion_control_t *,
|
||||||
uint64_t);
|
uint64_t);
|
||||||
static bool congestion_control_update_circuit_bdp(congestion_control_t *,
|
static bool congestion_control_update_circuit_bdp(congestion_control_t *,
|
||||||
@ -53,6 +56,34 @@ static bool congestion_control_update_circuit_bdp(congestion_control_t *,
|
|||||||
const crypt_path_t *,
|
const crypt_path_t *,
|
||||||
uint64_t, uint64_t);
|
uint64_t, uint64_t);
|
||||||
|
|
||||||
|
static uint32_t cwnd_max = CWND_MAX_DFLT;
|
||||||
|
uint32_t or_conn_highwater = OR_CONN_HIGHWATER_DFLT;
|
||||||
|
uint32_t or_conn_lowwater = OR_CONN_LOWWATER_DFLT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update global congestion control related consensus parameter values,
|
||||||
|
* every consensus update.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
congestion_control_new_consensus_params(const networkstatus_t *ns)
|
||||||
|
{
|
||||||
|
#define OR_CONN_HIGHWATER_MIN (CELL_PAYLOAD_SIZE)
|
||||||
|
#define OR_CONN_HIGHWATER_MAX (INT32_MAX)
|
||||||
|
or_conn_highwater =
|
||||||
|
networkstatus_get_param(ns, "orconn_high",
|
||||||
|
OR_CONN_HIGHWATER_DFLT,
|
||||||
|
OR_CONN_HIGHWATER_MIN,
|
||||||
|
OR_CONN_HIGHWATER_MAX);
|
||||||
|
|
||||||
|
#define OR_CONN_LOWWATER_MIN (CELL_PAYLOAD_SIZE)
|
||||||
|
#define OR_CONN_LOWWATER_MAX (INT32_MAX)
|
||||||
|
or_conn_lowwater =
|
||||||
|
networkstatus_get_param(ns, "orconn_low",
|
||||||
|
OR_CONN_LOWWATER_DFLT,
|
||||||
|
OR_CONN_LOWWATER_MIN,
|
||||||
|
OR_CONN_LOWWATER_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set congestion control parameters on a circuit's congestion
|
* Set congestion control parameters on a circuit's congestion
|
||||||
* control object based on values from the consensus.
|
* control object based on values from the consensus.
|
||||||
|
@ -41,6 +41,27 @@ int sendme_get_inc_count(const circuit_t *, const crypt_path_t *);
|
|||||||
bool circuit_sent_cell_for_sendme(const circuit_t *, const crypt_path_t *);
|
bool circuit_sent_cell_for_sendme(const circuit_t *, const crypt_path_t *);
|
||||||
bool is_monotime_clock_reliable(void);
|
bool is_monotime_clock_reliable(void);
|
||||||
|
|
||||||
|
void congestion_control_new_consensus_params(const networkstatus_t *ns);
|
||||||
|
|
||||||
|
/* Ugh, C.. these two are private. Use the getter instead, when
|
||||||
|
* external to the congestion control code. */
|
||||||
|
extern uint32_t or_conn_highwater;
|
||||||
|
extern uint32_t or_conn_lowwater;
|
||||||
|
|
||||||
|
/** Stop writing on an orconn when its outbuf is this large */
|
||||||
|
static inline uint32_t
|
||||||
|
or_conn_highwatermark(void)
|
||||||
|
{
|
||||||
|
return or_conn_highwater;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Resume writing on an orconn when its outbuf is less than this */
|
||||||
|
static inline uint32_t
|
||||||
|
or_conn_lowwatermark(void)
|
||||||
|
{
|
||||||
|
return or_conn_lowwater;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute an N-count EWMA, aka N-EWMA. N-EWMA is defined as:
|
* Compute an N-count EWMA, aka N-EWMA. N-EWMA is defined as:
|
||||||
* EWMA = alpha*value + (1-alpha)*EWMA_prev
|
* EWMA = alpha*value + (1-alpha)*EWMA_prev
|
||||||
|
@ -65,6 +65,7 @@
|
|||||||
#include "core/or/scheduler.h"
|
#include "core/or/scheduler.h"
|
||||||
#include "feature/nodelist/torcert.h"
|
#include "feature/nodelist/torcert.h"
|
||||||
#include "core/or/channelpadding.h"
|
#include "core/or/channelpadding.h"
|
||||||
|
#include "core/or/congestion_control_common.h"
|
||||||
#include "feature/dirauth/authmode.h"
|
#include "feature/dirauth/authmode.h"
|
||||||
#include "feature/hs/hs_service.h"
|
#include "feature/hs/hs_service.h"
|
||||||
|
|
||||||
@ -636,7 +637,7 @@ connection_or_flushed_some(or_connection_t *conn)
|
|||||||
/* If we're under the low water mark, add cells until we're just over the
|
/* If we're under the low water mark, add cells until we're just over the
|
||||||
* high water mark. */
|
* high water mark. */
|
||||||
datalen = connection_get_outbuf_len(TO_CONN(conn));
|
datalen = connection_get_outbuf_len(TO_CONN(conn));
|
||||||
if (datalen < OR_CONN_LOWWATER) {
|
if (datalen < or_conn_lowwatermark()) {
|
||||||
/* Let the scheduler know */
|
/* Let the scheduler know */
|
||||||
scheduler_channel_wants_writes(TLS_CHAN_TO_BASE(conn->chan));
|
scheduler_channel_wants_writes(TLS_CHAN_TO_BASE(conn->chan));
|
||||||
}
|
}
|
||||||
@ -660,9 +661,9 @@ connection_or_num_cells_writeable(or_connection_t *conn)
|
|||||||
* used to trigger when to start writing after we've stopped.
|
* used to trigger when to start writing after we've stopped.
|
||||||
*/
|
*/
|
||||||
datalen = connection_get_outbuf_len(TO_CONN(conn));
|
datalen = connection_get_outbuf_len(TO_CONN(conn));
|
||||||
if (datalen < OR_CONN_HIGHWATER) {
|
if (datalen < or_conn_highwatermark()) {
|
||||||
cell_network_size = get_cell_network_size(conn->wide_circ_ids);
|
cell_network_size = get_cell_network_size(conn->wide_circ_ids);
|
||||||
n = CEIL_DIV(OR_CONN_HIGHWATER - datalen, cell_network_size);
|
n = CEIL_DIV(or_conn_highwatermark() - datalen, cell_network_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
|
@ -594,18 +594,6 @@ typedef struct or_handshake_state_t or_handshake_state_t;
|
|||||||
|
|
||||||
/** Length of Extended ORPort connection identifier. */
|
/** Length of Extended ORPort connection identifier. */
|
||||||
#define EXT_OR_CONN_ID_LEN DIGEST_LEN /* 20 */
|
#define EXT_OR_CONN_ID_LEN DIGEST_LEN /* 20 */
|
||||||
/*
|
|
||||||
* OR_CONN_HIGHWATER and OR_CONN_LOWWATER moved from connection_or.c so
|
|
||||||
* channeltls.c can see them too.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** When adding cells to an OR connection's outbuf, keep adding until the
|
|
||||||
* outbuf is at least this long, or we run out of cells. */
|
|
||||||
#define OR_CONN_HIGHWATER (32*1024)
|
|
||||||
|
|
||||||
/** Add cells to an OR connection's outbuf whenever the outbuf's data length
|
|
||||||
* drops below this size. */
|
|
||||||
#define OR_CONN_LOWWATER (16*1024)
|
|
||||||
|
|
||||||
typedef struct connection_t connection_t;
|
typedef struct connection_t connection_t;
|
||||||
typedef struct control_connection_t control_connection_t;
|
typedef struct control_connection_t control_connection_t;
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include "core/or/channel.h"
|
#include "core/or/channel.h"
|
||||||
#include "core/or/channelpadding.h"
|
#include "core/or/channelpadding.h"
|
||||||
#include "core/or/circuitpadding.h"
|
#include "core/or/circuitpadding.h"
|
||||||
|
#include "core/or/congestion_control_common.h"
|
||||||
#include "core/or/congestion_control_flow.h"
|
#include "core/or/congestion_control_flow.h"
|
||||||
#include "core/or/circuitmux.h"
|
#include "core/or/circuitmux.h"
|
||||||
#include "core/or/circuitmux_ewma.h"
|
#include "core/or/circuitmux_ewma.h"
|
||||||
@ -1700,6 +1701,7 @@ notify_after_networkstatus_changes(void)
|
|||||||
channelpadding_new_consensus_params(c);
|
channelpadding_new_consensus_params(c);
|
||||||
circpad_new_consensus_params(c);
|
circpad_new_consensus_params(c);
|
||||||
router_new_consensus_params(c);
|
router_new_consensus_params(c);
|
||||||
|
congestion_control_new_consensus_params(c);
|
||||||
flow_control_new_consensus_params(c);
|
flow_control_new_consensus_params(c);
|
||||||
|
|
||||||
/* Maintenance of our L2 guard list */
|
/* Maintenance of our L2 guard list */
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "lib/tls/tortls.h"
|
#include "lib/tls/tortls.h"
|
||||||
|
|
||||||
#include "core/or/or_connection_st.h"
|
#include "core/or/or_connection_st.h"
|
||||||
|
#include "core/or/congestion_control_common.h"
|
||||||
|
|
||||||
/* Test suite stuff */
|
/* Test suite stuff */
|
||||||
#include "test/test.h"
|
#include "test/test.h"
|
||||||
@ -155,7 +156,7 @@ test_channeltls_num_bytes_queued(void *arg)
|
|||||||
* - 2 cells.
|
* - 2 cells.
|
||||||
*/
|
*/
|
||||||
n = ch->num_cells_writeable(ch);
|
n = ch->num_cells_writeable(ch);
|
||||||
tt_int_op(n, OP_EQ, CEIL_DIV(OR_CONN_HIGHWATER, 512) - 2);
|
tt_int_op(n, OP_EQ, CEIL_DIV(or_conn_highwatermark(), 512) - 2);
|
||||||
UNMOCK(buf_datalen);
|
UNMOCK(buf_datalen);
|
||||||
tlschan_buf_datalen_mock_target = NULL;
|
tlschan_buf_datalen_mock_target = NULL;
|
||||||
tlschan_buf_datalen_mock_size = 0;
|
tlschan_buf_datalen_mock_size = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user