Clean up UX decision logic; hardcode for browser UX case.

This commit is contained in:
Mike Perry 2023-05-09 20:11:41 +00:00
parent c8341abf82
commit a340acb492
3 changed files with 16 additions and 21 deletions

View File

@ -266,22 +266,13 @@ conflux_cell_parse_linked(const cell_t *cell, const uint16_t cell_len)
conflux_cell_link_t * conflux_cell_link_t *
conflux_cell_new_link(const uint8_t *nonce, uint64_t last_seqno_sent, conflux_cell_new_link(const uint8_t *nonce, uint64_t last_seqno_sent,
uint64_t last_seqno_recv, bool is_client) uint64_t last_seqno_recv, uint8_t ux)
{ {
conflux_cell_link_t *link = tor_malloc_zero(sizeof(*link)); conflux_cell_link_t *link = tor_malloc_zero(sizeof(*link));
link->version = 0x01; link->version = 0x01;
if (is_client) { link->desired_ux = ux;
// TODO-329-TUNING: The default should probably be high-throughput,
// but mobile clients may want to use low-memory.. We may also want
// to move this choice upstairs, so that torrc can control it.
link->desired_ux = CONFLUX_UX_HIGH_THROUGHPUT;
} else {
// TODO-329-TUNING: For exits, the default should be min-latency
// but we need to fix the tests and evaluate this first.
//link->desired_ux = CONFLUX_UX_MIN_LATENCY;
link->desired_ux = CONFLUX_UX_HIGH_THROUGHPUT;
}
link->last_seqno_sent = last_seqno_sent; link->last_seqno_sent = last_seqno_sent;
link->last_seqno_recv = last_seqno_recv; link->last_seqno_recv = last_seqno_recv;
memcpy(link->nonce, nonce, sizeof(link->nonce)); memcpy(link->nonce, nonce, sizeof(link->nonce));

View File

@ -23,7 +23,7 @@ typedef struct conflux_cell_link_t {
conflux_cell_link_t *conflux_cell_new_link(const uint8_t *nonce, conflux_cell_link_t *conflux_cell_new_link(const uint8_t *nonce,
uint64_t last_sent, uint64_t last_sent,
uint64_t last_recv, uint64_t last_recv,
bool is_client); uint8_t ux);
conflux_cell_link_t *conflux_cell_parse_link(const cell_t *cell, conflux_cell_link_t *conflux_cell_parse_link(const cell_t *cell,
const uint16_t cell_len); const uint16_t cell_len);

View File

@ -143,18 +143,19 @@ fmt_nonce(const uint8_t *nonce)
static uint8_t static uint8_t
conflux_choose_algorithm(uint8_t desired_ux) conflux_choose_algorithm(uint8_t desired_ux)
{ {
/* TODO-329-TUNING: Pick better algs here*/
switch (desired_ux) { switch (desired_ux) {
case CONFLUX_UX_NO_OPINION: case CONFLUX_UX_NO_OPINION:
return CONFLUX_ALG_LOWRTT; return CONFLUX_ALG_LOWRTT;
case CONFLUX_UX_MIN_LATENCY: case CONFLUX_UX_MIN_LATENCY:
return CONFLUX_ALG_MINRTT; return CONFLUX_ALG_MINRTT;
case CONFLUX_UX_LOW_MEM_LATENCY:
return CONFLUX_ALG_MINRTT;
case CONFLUX_UX_LOW_MEM_THROUGHPUT:
return CONFLUX_ALG_CWNDRTT;
case CONFLUX_UX_HIGH_THROUGHPUT: case CONFLUX_UX_HIGH_THROUGHPUT:
return CONFLUX_ALG_LOWRTT; return CONFLUX_ALG_LOWRTT;
/* For now, we have no low mem algs, so use minRTT since it should
* switch less and thus use less mem */
/* TODO-329-TUNING: Pick better algs here*/
case CONFLUX_UX_LOW_MEM_THROUGHPUT:
case CONFLUX_UX_LOW_MEM_LATENCY:
return CONFLUX_ALG_MINRTT;
default: default:
/* Trunnel should protect us from this */ /* Trunnel should protect us from this */
tor_assert_nonfatal_unreached(); tor_assert_nonfatal_unreached();
@ -1105,11 +1106,12 @@ conflux_launch_leg(const uint8_t *nonce)
// arti-relay could (if resumption seems worthwhile; it may not be worth the // arti-relay could (if resumption seems worthwhile; it may not be worth the
// memory storage there, either). // memory storage there, either).
/* We have a circuit, create the new leg and attach it to the set. */ /* We have a circuit, create the new leg and attach it to the set.
* TODO-329-TUNING: Should we make a torrc option to request min latency? */
leg_t *leg = leg_new(TO_CIRCUIT(circ), leg_t *leg = leg_new(TO_CIRCUIT(circ),
conflux_cell_new_link(nonce, conflux_cell_new_link(nonce,
last_seq_sent, last_seq_recv, last_seq_sent, last_seq_recv,
true)); CONFLUX_UX_HIGH_THROUGHPUT));
/* Increase the retry count for this conflux object as in this nonce. */ /* Increase the retry count for this conflux object as in this nonce. */
unlinked->cfx->num_leg_launch++; unlinked->cfx->num_leg_launch++;
@ -1760,8 +1762,10 @@ conflux_process_link(circuit_t *circ, const cell_t *cell,
goto end; goto end;
} }
/* Exits should always request min latency from clients */
conflux_cell_link_t *linked = conflux_cell_new_link(nonce, last_seq_sent, conflux_cell_link_t *linked = conflux_cell_new_link(nonce, last_seq_sent,
last_seq_recv, false); last_seq_recv,
CONFLUX_UX_MIN_LATENCY);
conflux_cell_send_linked(linked, TO_OR_CIRCUIT(circ)); conflux_cell_send_linked(linked, TO_OR_CIRCUIT(circ));
tor_free(linked); tor_free(linked);