Skip to content

Commit

Permalink
Increase value of $max_recent_bandwidth_usages
Browse files Browse the repository at this point in the history
After running fine for 90 days the script suddenly died because it couldn't find a record of the bandwidth usage for a particular time slot:

Fri Jul 21 15:47:36.167 2023 [6150-0015312751]: FATAL ERROR: Failed to get upload bandwidth at 15:47:13.287. Earliest of 45 (max 45) bandwidth samples' start time = 15:47:13.464

It seems that in some strange and rare circumstances the number I calculate for $max_recent_bandwidth_usages is not sufficient.

This is going to be very tricky to debug if it only happens once every three months, so this patch just artificially increases $max_recent_bandwidth_usages slightly so we should be covered. I was actually already bumping it slightly, but evidently  that arbitrary bump of 2 wasn't enough, so I've increased it to 10.

As mentioned in the code there should be zero performance impact - just a *tiny* increase in memory usage.
  • Loading branch information
tievolu authored Jul 21, 2023
1 parent a369a97 commit 242a333
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sqm-autorate.pl
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@
# couple of extra samples does not impact performance because we always search backwards
# starting with the most recent sample. Redundant samples at the end of the array have
# no impact beyond a *tiny* increase in memory usage.
my $max_for_adaptive_idle_delay = $icmp_adaptive ? &round_up($icmp_adaptive_idle_delay / $latency_check_interval) + 2 : 0;
my $max_for_icmp_results = &round_up( (((max($icmp_interval_loaded, $icmp_interval_idle, 1) * $max_recent_results) + $icmp_timeout) / $latency_check_interval) ) + 2;
my $max_for_adaptive_idle_delay = $icmp_adaptive ? &round_up($icmp_adaptive_idle_delay / $latency_check_interval) + 10 : 0;
my $max_for_icmp_results = &round_up( (((max($icmp_interval_loaded, $icmp_interval_idle, 1) * $max_recent_results) + $icmp_timeout) / $latency_check_interval) ) + 10;
my $max_recent_bandwidth_usages = max($max_for_icmp_results, $max_for_adaptive_idle_delay);

# Create an array to store the recent bandwidth usage statistics, and initialise it
Expand Down

0 comments on commit 242a333

Please sign in to comment.