refactor: increase score hysteresis from 2% to 10% for enhanced mode

Increase SWITCH_THRESHOLD from 1.02 to 1.10 so a new connection must be
10% better before traffic is moved to it.  With the shorter 15ms cooldown,
hysteresis is now the primary stability mechanism; 2% was too small to
prevent noise-driven flip-flopping between connections with similar scores.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
datagutt
2026-02-11 20:57:28 +01:00
parent 86039ff038
commit 082d118dac
2 changed files with 9 additions and 8 deletions
+3 -3
View File
@@ -36,7 +36,7 @@ The sender supports three mutually exclusive scheduling modes:
- **NAK Burst Detection**: Extra penalties for connections experiencing severe packet loss (≥5 NAKs)
- **RTT-Aware Selection**: Small bonus (3% max) for lower-latency connections
- **Quality Scoring**: Automatic preference for higher-quality connections
- **Minimal Hysteresis**: 2% threshold prevents flip-flopping while maintaining natural load distribution
- **Score Hysteresis**: 10% threshold prevents noise-driven flip-flopping while maintaining natural load distribution
#### Classic Mode
@@ -346,7 +346,7 @@ With properly configured connections, you should observe:
**If connections are flip-flopping**:
1. This should be minimal with 2% hysteresis in enhanced mode
1. This should be minimal with 10% hysteresis in enhanced mode
2. Check if scores are truly identical (look for hysteresis messages in debug logs)
3. Verify connections have stable quality (no intermittent NAKs)
4. Consider using classic mode for perfectly equal connections
@@ -359,7 +359,7 @@ If needed, these can be adjusted in `src/sender/selection/`:
**Enhanced Mode (`enhanced.rs`):**
- `SWITCH_THRESHOLD`: 1.02 (2% hysteresis) - increase for more stability, decrease for faster response
- `SWITCH_THRESHOLD`: 1.10 (10% hysteresis) - increase for more stability, decrease for faster response
**Quality Scoring (`quality.rs`):**
+6 -5
View File
@@ -3,7 +3,7 @@
//! This module implements the enhanced SRTLA connection selection with:
//! - Quality-aware scoring based on NAK history
//! - RTT-aware bonuses for low-latency connections
//! - Minimal hysteresis to prevent flip-flopping (2%)
//! - Score hysteresis to prevent flip-flopping (10%)
//! - Optional smart exploration of alternative connections
//!
//! The enhanced mode provides better connection quality awareness while
@@ -15,10 +15,11 @@ use super::MIN_SWITCH_INTERVAL_MS;
use super::exploration::should_explore_now;
use crate::connection::SrtlaConnection;
/// Switching hysteresis: require new connection to be significantly better
/// REDUCED to 2% to allow better load distribution across multiple connections
/// Original 15% was preventing traffic from spreading across all uplinks
const SWITCH_THRESHOLD: f64 = 1.02; // New connection must be 2% better
/// Switching hysteresis: require new connection to be meaningfully better.
/// At 10%, this prevents noise-driven flip-flopping between connections with
/// similar scores while still allowing switches when one connection genuinely
/// degrades (e.g., higher in_flight due to congestion or packet loss).
const SWITCH_THRESHOLD: f64 = 1.10; // New connection must be 10% better
/// Select best connection using enhanced algorithm with quality awareness
///