From: Johannes Truschnigg Date: Sat, 19 Mar 2022 16:56:33 +0000 (+0100) Subject: Implement TREND_DECISION tunable X-Git-Url: https://johannes.truschnigg.info/gitweb/?a=commitdiff_plain;h=e414e17da65d71cf6c432b57bff5d5f711dac28a;p=sqm_lagthrottle Implement TREND_DECISION tunable --- diff --git a/__lagdetect.awk b/__lagdetect.awk index ad5406c..8b2bd32 100644 --- a/__lagdetect.awk +++ b/__lagdetect.awk @@ -29,6 +29,7 @@ BEGIN { print "# INIT=" systime() print "# THRESHOLD=" THRESHOLD print "# FUDGE=" FUDGE + print "# DECISION=" DECISION print "# PINGSLOTS=" PINGSLOTS print "# BW_MAX_RX=" BW_MAX_RX print "# BW_MIN_RX=" BW_MIN_RX @@ -56,7 +57,18 @@ BEGIN { rx_rate_max = 100 # make something up tx_rate_max = 100 # make something up update_bw() - update_bw_min_delta = (0.02 * peer_count) + if (DECISION == "eager") { + update_bw_min_delta = 0.02 + decision_pingslots_factor = 3 + adjust_sqm_mindelta = 0.5 + } else if (DECISION == "relaxed") { + update_bw_min_delta = (0.02 * peer_count) + decision_pingslots_factor = 5 + adjust_sqm_mindelta = 1 + } else { + print "FATAL: BOGUS DECISION SETTING: " DECISION + exit 1 + } } @@ -90,7 +102,7 @@ BEGIN { # XXX TODO impl. tunable for acting more fine-grained? function slice_bw_window_rx(bw_lower_bound_rx, bw_upper_bound_rx) { bw_bound_delta_rx = (bw_upper_bound_rx - bw_lower_bound_rx) - bw_steps_rx = 1+int((log(bw_bound_delta_rx)/log(10)) ^ 1.6) + bw_steps_rx = 1 + int((log(bw_bound_delta_rx) / log(10)) ^ 1.6) print "# STEPS_RX=" bw_steps_rx for (k = 0; k <= bw_steps_rx; k++) { STEPS_RX[k] = int((bw_lower_bound_rx + (k * (bw_bound_delta_rx / bw_steps_rx)))) @@ -109,7 +121,7 @@ function update_ts() { ts_delta = ts - ts_old if (ts_delta < update_bw_min_delta) { # Let caller know that not much time has passed since the last update, - # so maybe not waste time with useless calculations in the face of very + # so maybe not waste time with pointless calculations in the face of very # little actual change. return 0 } @@ -196,8 +208,8 @@ function process_record(pn, bytes, lat) { function adjust_sqm(peername, latency) { adjust_ts_delta = (ts - adjust_old) - # Do not try to adjust bw more than once a second. - if (adjust_ts_delta < 1.0) { + # Do not try to adjust bw more than the DECISION policy dictates + if (adjust_ts_delta < adjust_sqm_mindelta) { # print "# " ts " looping too fast, skipping SQM update adjust_ts_delta=" adjust_ts_delta return } @@ -243,7 +255,7 @@ function adjust_sqm(peername, latency) { } 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 (not_increasing_count[peername] > (5 * PINGSLOTS)) { + if (not_increasing_count[peername] > (decision_pingslots_factor * PINGSLOTS)) { if (bw_cur_step_rx < bw_maxindex_rx) { bw_next_step_rx = bw_cur_step_rx + 1 print "+++ " ts " choosing bw rx step " bw_next_step_rx " := " STEPS_RX[bw_next_step_rx] "Kbps rx=" rx_rate " tx=" tx_rate diff --git a/lagdetect.sh b/lagdetect.sh index 331cf63..54492b3 100755 --- a/lagdetect.sh +++ b/lagdetect.sh @@ -36,6 +36,7 @@ STATS_TX='/sys/class/net/eth1/statistics/tx_bytes' # upstream bandwidth accounti IFACE_TX='eth1' # interface to apply upstream SQM to (presently not used) BW_MIN_RX=10000 # your min. acceptable downstream bandwidth to shape to in Kbps BW_MAX_RX=30000 # your max. desired downstream bandwidth to shape to in Kbps +TREND_DECISION="relaxed" # choose either "eager" or "relaxed" - the latter trades additional CPU load for quicker decision making @@ -189,6 +190,18 @@ do done +case "${TREND_DECISION}" in + eager) + ;; + relaxed) + ;; + *) + printf 'FATAL: Interface "%s" does not seem to have cake SQM set up\n' "${i}" + exit 1 + ;; +esac + + set -u @@ -201,6 +214,7 @@ fping --loop --retry=1 --size=1280 --period="${PING_INTERVAL}" --random ${PING_P -v BW_MIN_RX="${BW_MIN_RX}" \ -v BW_MAX_RX="${BW_MAX_RX}" \ -v THRESHOLD="${THRESHOLD}" \ + -v DECISION="${TREND_DECISION}" \ -v PINGSLOTS="${PING_SLOTS_PER_PEER}" \ -v FUDGE="${FUDGE_MS}" \ -v PING_PEERS="${PING_PEERS}" \