commit 0e0564672f92ef8332b0707e7ad5ddfa0e25dd68 Author: Mike Perry mikeperry-git@fscked.org Date: Fri Dec 2 16:17:16 2011 -0800
Implement mercy, subject to consensus parameter.
If the param is set, we don't accumulate negative pid_error_sum for nodes with negative pid_error. Prevents us from punishing these nodes to 0 bw. The param only makes sense for descriptor-based feedback. --- NetworkScanners/BwAuthority/README.spec.txt | 8 ++++++++ NetworkScanners/BwAuthority/aggregate.py | 22 ++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/NetworkScanners/BwAuthority/README.spec.txt b/NetworkScanners/BwAuthority/README.spec.txt index 175a9fb..64827cb 100644 --- a/NetworkScanners/BwAuthority/README.spec.txt +++ b/NetworkScanners/BwAuthority/README.spec.txt @@ -550,6 +550,14 @@ Note that this parameter causes bwauthbestratio to have no effect.
+ "bwauthmercy=1" + If present, we do not accumulate a negative pid_error_sum for + nodes with already negative pid_error. This prevents us from + punishing relays down to 0 bandwidth. + + Note that this parameter has no effect unless you omit bwauthnsbw=1 + and also set a bwauthti value of non-zero. + "bwauthkp=N" Sets K_p to N/10000.0. If absent, K_p=1.0.
diff --git a/NetworkScanners/BwAuthority/aggregate.py b/NetworkScanners/BwAuthority/aggregate.py index 615a157..b3692e8 100755 --- a/NetworkScanners/BwAuthority/aggregate.py +++ b/NetworkScanners/BwAuthority/aggregate.py @@ -123,14 +123,16 @@ class Node: + kd*self.use_bw*self.pid_delta
self.prev_error = prev_vote.pid_error - # We decay the interval each round to keep it bounded. - # This decay is non-standard. We do it to avoid overflow - self.pid_error_sum = prev_vote.pid_error_sum*kidecay + self.pid_error
self.pid_bw = self.use_bw \ + kp*self.use_bw*self.pid_error \ + ki*self.use_bw*self.integral_error() \ + kd*self.use_bw*self.d_error_dt() + + # We decay the interval each round to keep it bounded. + # This decay is non-standard. We do it to avoid overflow + self.pid_error_sum = prev_vote.pid_error_sum*kidecay + self.pid_error + return self.pid_bw
def node_class(self): @@ -238,6 +240,7 @@ class ConsensusJunk: self.use_circ_fails = False self.use_best_ratio = True self.use_desc_bw = True + self.use_mercy = False
self.K_p = K_p self.T_i = T_i @@ -252,7 +255,7 @@ class ConsensusJunk: self.bwauth_pid_control = False elif p == "bwauthnsbw=1": self.use_desc_bw = False - plog("INFO", "Using descriptor bandwidth") + plog("INFO", "Using NS bandwidth directly for feedback") elif p == "bwauthcircs=1": self.use_circ_fails = True plog("INFO", "Counting circuit failures") @@ -265,6 +268,9 @@ class ConsensusJunk: elif p == "bwauthpidtgt=1": self.use_pid_tgt = True plog("INFO", "Using filtered PID target") + elif p == "bwauthmercy=1": + self.use_mercy = True + plog("INFO", "Showing mercy on gimpy nodes") elif p.startswith("bwauthkp="): self.K_p = int(p.split("=")[1])/10000.0 plog("INFO", "Got K_p=%f from consensus." % self.K_p) @@ -573,6 +579,14 @@ def main(argv): if circ_error < 0: n.pid_error = min(circ_error,n.pid_error)
+ # Don't punish gimpy nodes too hard + if cs_junk.use_mercy: + if not cs_junk.use_desc_bw: + plog("WARN", + "Can't be merciful w/ NS feedback! Set bwauthnsbw=0 and bwauthti!=0") + if n.pid_error_sum < 0 and n.pid_error < 0: + n.pid_error_sum = 0 + if n.idhex in prev_votes.vote_map: # If there is a new sample, let's use it for all but guards if n.measured_at > prev_votes.vote_map[n.idhex].measured_at:
tor-commits@lists.torproject.org