aboutsummaryrefslogtreecommitdiff
path: root/src/or/circuitlist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-12-12 00:49:48 -0500
committerNick Mathewson <nickm@torproject.org>2009-12-13 21:05:53 -0500
commit06e8370c33d6ccb73d55e9e8c3d2673c48d7b328 (patch)
tree2df32183173969c207b0247c9be225a087f9edb6 /src/or/circuitlist.c
parentc43fee131d306507937733c7ddc45a040dd2d27c (diff)
downloadtor-06e8370c33d6ccb73d55e9e8c3d2673c48d7b328.tar.gz
tor-06e8370c33d6ccb73d55e9e8c3d2673c48d7b328.zip
Optimize cell-ewma circuit priority algorithm.
There are two big changes here: - We store active circuits in a priority queue for each or_conn, rather than doing a linear search over all the active circuits before we send each cell. - Rather than multiplying every circuit's cell-ewma by a decay factor every time we send a cell (thus normalizing the value of a current cell to 1.0 and a past cell to alpha^t), we instead only scale down the cell-ewma every tick (ten seconds atm), normalizing so that a cell sent at the start of the tick has value 1.0).
Diffstat (limited to 'src/or/circuitlist.c')
-rw-r--r--src/or/circuitlist.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index eb8c90f460..0dff873cf6 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -386,8 +386,10 @@ init_circuit_base(circuit_t *circ)
circ->deliver_window = CIRCWINDOW_START;
/* Initialize the cell_ewma_t structure */
- circ->n_cell_ewma.last_cell_time = circ->highres_created;
+ circ->n_cell_ewma.last_adjusted_tick = cell_ewma_get_tick();
circ->n_cell_ewma.cell_count = 0.0;
+ circ->n_cell_ewma.heap_index = -1;
+ circ->n_cell_ewma.is_for_p_conn = 0;
circuit_add(circ);
}
@@ -438,11 +440,13 @@ or_circuit_new(circid_t p_circ_id, or_connection_t *p_conn)
/* Initialize the cell_ewma_t structure */
- /* Fetch the timeval that init_circuit_base filled in. */
- circ->p_cell_ewma.last_cell_time = TO_CIRCUIT(circ)->highres_created;
-
/* Initialize the cell counts to 0 */
circ->p_cell_ewma.cell_count = 0.0;
+ circ->p_cell_ewma.last_adjusted_tick = cell_ewma_get_tick();
+ circ->p_cell_ewma.is_for_p_conn = 1;
+
+ /* It's not in any heap yet. */
+ circ->p_cell_ewma.heap_index = -1;
return circ;
}