diff options
author | Can Tang <c24tang@uwaterloo.ca> | 2009-12-10 11:12:42 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2009-12-12 19:06:38 -0500 |
commit | d3be00e0f454998db6387c8547d218a0db93db21 (patch) | |
tree | c2a90125dd9da2cdd283cf045be7fb3ec02d7745 /src/or/connection.c | |
parent | c210db0d41f4a47496e12c0af829f8ae0a5c2cd2 (diff) | |
download | tor-d3be00e0f454998db6387c8547d218a0db93db21.tar.gz tor-d3be00e0f454998db6387c8547d218a0db93db21.zip |
Favor quiet circuits when choosing which order to relay cells in.
Each circuit is ranked in terms of how many cells from it have been
relayed recently, using a time-weighted average.
This patch has been tested this on a private Tor network on PlanetLab,
and gotten improvements of 12-35% in time it takes to fetch a small
web page while there's a simultaneous large data transfer going on
simultaneously.
[Commit msg by nickm based on mail from Ian Goldberg.]
Diffstat (limited to 'src/or/connection.c')
-rw-r--r-- | src/or/connection.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index 0ff1cc5876..bd12e36180 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -2275,8 +2275,8 @@ connection_read_bucket_should_increase(or_connection_t *conn) * Mark the connection and return -1 if you want to close it, else * return 0. */ -int -connection_handle_read(connection_t *conn) +static int +connection_handle_read_impl(connection_t *conn) { int max_to_read=-1, try_to_read; size_t before, n_read = 0; @@ -2371,6 +2371,17 @@ loop_again: return 0; } +int +connection_handle_read(connection_t *conn) +{ + int res; + + tor_gettimeofday_cache_clear(); + res = connection_handle_read_impl(conn); + return res; + +} + /** Pull in new bytes from conn-\>s or conn-\>linked_conn onto conn-\>inbuf, * either directly or via TLS. Reduce the token buckets by the number of bytes * read. @@ -2572,8 +2583,8 @@ connection_outbuf_too_full(connection_t *conn) * Mark the connection and return -1 if you want to close it, else * return 0. */ -int -connection_handle_write(connection_t *conn, int force) +static int +connection_handle_write_impl(connection_t *conn, int force) { int e; socklen_t len=(socklen_t)sizeof(e); @@ -2740,6 +2751,15 @@ connection_handle_write(connection_t *conn, int force) return 0; } +int +connection_handle_write(connection_t *conn, int force) +{ + int res; + tor_gettimeofday_cache_clear(); + res = connection_handle_write_impl(conn, force); + return res; +} + /** OpenSSL TLS record size is 16383; this is close. The goal here is to * push data out as soon as we know there's enough for a TLS record, so * during periods of high load we won't read entire megabytes from |