Skip to content

Commit

Permalink
Merge 47df912 into 31fbbf2
Browse files Browse the repository at this point in the history
  • Loading branch information
nmathewson committed Apr 17, 2018
2 parents 31fbbf2 + 47df912 commit 7f9b570
Show file tree
Hide file tree
Showing 11 changed files with 251 additions and 169 deletions.
7 changes: 7 additions & 0 deletions changes/bug25373
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
o Major features (main loop, CPU wakeup):
- The bandwidth-limitation logic has been refactored so that
bandwidth calculations are performed on-demand, rather than
every TokenBucketRefillInterval milliseconds.
This change should improve the granularity of our bandwidth
calculations, and limit the number of times that the Tor process needs
to wake up when it is idle. Closes ticket 25373.
7 changes: 7 additions & 0 deletions changes/bug25828
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
o Minor bugfixes (bandwidth management):
- Consider ourselves "low on write bandwidth" if we have exhausted our
write bandwidth some time in the last second. This was the
documented behavior before, but the actual behavior was to change
this value every TokenBucketRefillInterval. Fixes bug 25828; bugfix on
0.2.3.5-alpha.

8 changes: 5 additions & 3 deletions doc/tor.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1285,9 +1285,11 @@ The following options are useful only for clients (that is, if
2 minutes)

[[TokenBucketRefillInterval]] **TokenBucketRefillInterval** __NUM__ [**msec**|**second**]::
Set the refill interval of Tor's token bucket to NUM milliseconds.
NUM must be between 1 and 1000, inclusive. Note that the configured
bandwidth limits are still expressed in bytes per second: this
Set the refill delay interval of Tor's token bucket to NUM milliseconds.
NUM must be between 1 and 1000, inclusive. When Tor is out of bandwidth,
on a connection or globally, it will wait up to this long before it tries
to use that connection again.
Note that bandwidth limits are still expressed in bytes per second: this
option only affects the frequency with which Tor checks to see whether
previously exhausted connections may read again.
Can not be changed while tor is running. (Default: 100 msec)
Expand Down
13 changes: 9 additions & 4 deletions src/common/token_bucket.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,18 @@ token_bucket_rw_dec_write(token_bucket_rw_t *bucket,

/**
* As token_bucket_rw_dec_read and token_bucket_rw_dec_write, in a single
* operation.
* operation. Return a bitmask of TB_READ and TB_WRITE to indicate
* which buckets became empty.
*/
void
int
token_bucket_rw_dec(token_bucket_rw_t *bucket,
ssize_t n_read, ssize_t n_written)
{
token_bucket_rw_dec_read(bucket, n_read);
token_bucket_rw_dec_write(bucket, n_written);
int flags = 0;
if (token_bucket_rw_dec_read(bucket, n_read))
flags |= TB_READ;
if (token_bucket_rw_dec_write(bucket, n_written))
flags |= TB_WRITE;
return flags;
}

4 changes: 2 additions & 2 deletions src/common/token_bucket.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ int token_bucket_rw_dec_read(token_bucket_rw_t *bucket,
int token_bucket_rw_dec_write(token_bucket_rw_t *bucket,
ssize_t n);

void token_bucket_rw_dec(token_bucket_rw_t *bucket,
ssize_t n_read, ssize_t n_written);
int token_bucket_rw_dec(token_bucket_rw_t *bucket,
ssize_t n_read, ssize_t n_written);

static inline size_t token_bucket_rw_get_read(const token_bucket_rw_t *bucket);
static inline size_t
Expand Down

0 comments on commit 7f9b570

Please sign in to comment.