commit 0300422f1f9a1c9ab6df2344a343898ee545082f Author: Mike Perry mikeperry-git@fscked.org Date: Sat Dec 3 16:53:44 2011 -0800
Allow us to cap feedback via consensus param.
Also demote a couple logs, and add a couple more. --- NetworkScanners/BwAuthority/README.spec.txt | 7 +++++++ NetworkScanners/BwAuthority/aggregate.py | 22 ++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/NetworkScanners/BwAuthority/README.spec.txt b/NetworkScanners/BwAuthority/README.spec.txt index e46994c..5eb0661 100644 --- a/NetworkScanners/BwAuthority/README.spec.txt +++ b/NetworkScanners/BwAuthority/README.spec.txt @@ -577,3 +577,10 @@ for the values of T_i that are relevant to us.
If T_i is 0 or absent, K_i_decay is set to 0. + + "bwauthpidmax=N" + Caps pid_error_sum feedback to N/10000.0. Can be used to prevent + runaway feedback loops for fast nodes. + + If absent, the default is 500.0, which translates to a 501X + multiplier of descriptor bandwidth. diff --git a/NetworkScanners/BwAuthority/aggregate.py b/NetworkScanners/BwAuthority/aggregate.py index ca26b2d..7af68aa 100755 --- a/NetworkScanners/BwAuthority/aggregate.py +++ b/NetworkScanners/BwAuthority/aggregate.py @@ -242,6 +242,7 @@ class ConsensusJunk: self.use_desc_bw = True self.use_mercy = False
+ self.pid_max = 500.0 self.K_p = K_p self.T_i = T_i self.T_d = T_d @@ -283,6 +284,9 @@ class ConsensusJunk: elif p.startswith("bwauthtidecay="): self.T_i_decay = (int(p.split("=")[1])/10000.0) plog("INFO", "Got T_i_decay=%f from consensus." % self.T_i_decay) + elif p.startswith("bwauthpidmax="): + self.pid_max = (int(p.split("=")[1])/10000.0) + plog("INFO", "Got pid_max=%f from consensus." % self.pid_max) except: plog("NOTICE", "Bw auth PID control disabled due to parse error.") traceback.print_exc() @@ -596,8 +600,22 @@ def main(argv): # If node was demoted in the past and we plan to demote it again, # let's just not and say we did. if n.desc_bw > n.ns_bw and n.pid_error < 0: + plog("INFO", "Showing mercy for node "+n.nick+"="+n.idhex) n.use_bw = n.desc_bw if n.pid_error_sum < 0 and n.pid_error < 0: + plog("INFO", "Showing mercy for node "+n.nick+"="+n.idhex+", pid_error_sum="+str(n.pid_error_sum)) + n.pid_error_sum = 0 + + # Similarly, don't accumulate too much amplification for + # fast nodes + if cs_junk.use_desc_bw: + if n.pid_error_sum > cs_junk.pid_max and n.pid_error > 0: + plog("INFO", "Capping feedback for node "+n.nick+"="+n.idhex+", pid_error_sum="+str(n.pid_error_sum)) + n.pid_error_sum = cs_junk.pid_max + else: + if float(n.ns_bw)/n.desc_bw > cs_junk.pid_max and n.pid_error > 0: + plog("INFO", "Capping feedback for node "+n.nick+"="+n.idhex) + n.pid_error = 0 n.pid_error_sum = 0
if n.idhex in prev_votes.vote_map: @@ -669,7 +687,7 @@ def main(argv): n.new_bw = n.use_bw + cs_junk.K_p*n.use_bw*n.pid_error n.pid_error_sum = n.pid_error n.pid_bw = n.new_bw - plog("INFO", "No prev vote for node "+n.nick+": Consensus feedback") + plog("DEBUG", "No prev vote for node "+n.nick+": Consensus feedback") else: # No PID feedback # Choose the larger between sbw and fbw if n.sbw_ratio > n.fbw_ratio: @@ -694,7 +712,7 @@ def main(argv): plog("INFO", "Skipping voting for guard "+n.nick) n.ignore = True elif "Authority" in prev_consensus[n.idhex].flags: - plog("INFO", "Skipping voting for authority "+n.nick) + plog("DEBUG", "Skipping voting for authority "+n.nick) n.ignore = True
# Go through the list and cap them to NODE_CAP