]> johannes.truschnigg.info Git - sqm_lagthrottle/commitdiff
Optimize accounting of adjust_old and not_increasing_count[peername]
authorJohannes Truschnigg <johannes@truschnigg.info>
Sat, 19 Mar 2022 19:39:28 +0000 (20:39 +0100)
committerJohannes Truschnigg <johannes@truschnigg.info>
Sat, 19 Mar 2022 19:39:28 +0000 (20:39 +0100)
__lagdetect.awk

index 452e71e4a2f6e7f0b6e0f42a7089660ff1983b67..2ab8ebfcfb8b046d1e8cf147aa42f4caf8873ca5 100644 (file)
@@ -230,7 +230,6 @@ function adjust_sqm(peername, latency) {
     bw_step_rx_cur = 0
     bw_step_rx_next = 0
     set_bw(IFACE_RX, STEPS_RX[bw_step_rx_next])
-    adjust_old = ts
     return
   }
 
@@ -259,19 +258,18 @@ function adjust_sqm(peername, latency) {
         }
       }
       # print "set adjust_old=" ts
-      adjust_old = ts
     }
     not_increasing_count[peername] = 0
   } else if (latency < (ping_prev[peername] + FUDGE / 2) && latency < (ping_pprev[peername] + FUDGE / 2) && ping_prev[peername] < (ping_pprev[peername] + FUDGE/2)) {
     if (prefer_high_bw == 0) { # no preference for high bw caps configured
       if (rx_rate < (0.9 * STEPS_RX[bw_step_rx_cur])) { # line not loaded close to current cap, so skip increasing bw
-        adjust_old = ts
        not_increasing_count[peername]++
         print "=== " ts " NOOP skiping increase; rx rate too far from current cap of "  STEPS_RX[bw_step_rx_cur] "Kbps rx=" rx_rate " tx=" tx_rate
        return
       }
     }
     if (not_increasing_count[peername] > (decision_pingslots_factor * PINGSLOTS)) {
+      not_increasing_count[peername] = 0
       if (bw_step_rx_cur < bw_maxindex_rx) {
         bw_step_rx_next = bw_step_rx_cur + 1
         print "+++ " ts " choosing bw rx step " bw_step_rx_next " := " STEPS_RX[bw_step_rx_next] "Kbps rx=" rx_rate " tx=" tx_rate
@@ -280,8 +278,6 @@ function adjust_sqm(peername, latency) {
       } else {
         print "+++ " ts " already at highest bw rx step " bw_step_rx_cur " rx=" rx_rate " tx=" tx_rate
       }
-      not_increasing_count[peername] = 0
-      adjust_old = ts
     }
     not_increasing_count[peername]++
   } else {
@@ -334,6 +330,7 @@ function update_ping_avgs(peername) {
 
 # Shell out to `tc` to update cake bandwidth settings
 function set_bw(dev, kbit) {
+  adjust_old = ts
   system("set -x; tc qdisc change root dev " dev " cake bandwidth " kbit "Kbit")
 }