Tune VPN fabric batching and flow windows

This commit is contained in:
2026-05-15 23:19:15 +03:00
parent fdf176bc5d
commit bf78af07a6
5 changed files with 22 additions and 16 deletions
@@ -19,9 +19,9 @@ const (
FabricDirectionClientToGateway = "client_to_gateway"
FabricDirectionGatewayToClient = "gateway_to_client"
defaultFabricFlowShardCount = 32
defaultFabricFlowShardCount = 8
defaultFabricFlowQueueCapacity = 1024
defaultFabricFlowParallelSendWindow = 4
defaultFabricFlowParallelSendWindow = 8
defaultFabricFlowQualityWindowCapacity = 32
defaultFabricFlowFailureThreshold = 2
defaultFabricFlowSlowSendThreshold = 2 * time.Second
@@ -332,8 +332,8 @@ func defaultFabricServiceChannelAdaptivePolicy() FabricServiceChannelAdaptivePol
ClassWindows: map[string]int{
FabricTrafficClassControl: defaultFabricFlowParallelSendWindow,
FabricTrafficClassInteractive: defaultFabricFlowParallelSendWindow,
FabricTrafficClassReliable: 3,
FabricTrafficClassBulk: 1,
FabricTrafficClassReliable: 6,
FabricTrafficClassBulk: 4,
FabricTrafficClassDroppable: 1,
},
})
@@ -361,8 +361,8 @@ func normalizeFabricServiceChannelAdaptivePolicy(policy FabricServiceChannelAdap
defaults := map[string]int{
FabricTrafficClassControl: policy.MaxParallelWindow,
FabricTrafficClassInteractive: policy.MaxParallelWindow,
FabricTrafficClassReliable: minPositive(policy.MaxParallelWindow, 3),
FabricTrafficClassBulk: 1,
FabricTrafficClassReliable: minPositive(policy.MaxParallelWindow, 6),
FabricTrafficClassBulk: minPositive(policy.MaxParallelWindow, 4),
FabricTrafficClassDroppable: 1,
}
next := map[string]int{}
@@ -538,12 +538,15 @@ func (s *FabricFlowScheduler) RecommendedParallelSendWindowForTrafficClass(traff
return maxWindow
}
if classPressure.hasDrops {
return classWindowLimit(s.adaptivePolicy, trafficClass, boundedParallelWindow(maxWindow/2))
return classWindowLimit(s.adaptivePolicy, trafficClass, 1)
}
if global.hasDrops {
return classWindowLimit(s.adaptivePolicy, trafficClass, boundedParallelWindow(maxWindow/2))
return classWindowLimit(s.adaptivePolicy, trafficClass, 1)
}
if global.highPressure && global.interactiveOrControlQueues > 0 {
if trafficClass == FabricTrafficClassBulk || trafficClass == FabricTrafficClassDroppable {
return classWindowLimit(s.adaptivePolicy, trafficClass, 1)
}
return classWindowLimit(s.adaptivePolicy, trafficClass, boundedParallelWindow(maxWindow/2))
}
if global.highPressure {
@@ -821,9 +824,12 @@ func (s *FabricFlowScheduler) recommendedParallelSendWindowForTrafficClassLocked
return maxWindow
}
if classPressure.hasDrops || globalPressure.hasDrops {
return classWindowLimit(s.adaptivePolicy, trafficClass, boundedParallelWindow(maxWindow/2))
return classWindowLimit(s.adaptivePolicy, trafficClass, 1)
}
if globalPressure.highPressure && globalPressure.interactiveOrControlQueues > 0 {
if trafficClass == FabricTrafficClassBulk || trafficClass == FabricTrafficClassDroppable {
return classWindowLimit(s.adaptivePolicy, trafficClass, 1)
}
return classWindowLimit(s.adaptivePolicy, trafficClass, boundedParallelWindow(maxWindow/2))
}
if globalPressure.highPressure {
@@ -1457,14 +1457,14 @@ func TestFabricFlowSchedulerProtectsInteractiveWindowDuringBulkPressure(t *testi
if got := scheduler.RecommendedParallelSendWindowForTrafficClass(FabricTrafficClassBulk, 4); got != 1 {
t.Fatalf("bulk adaptive window = %d, want 1", got)
}
if got := scheduler.RecommendedParallelSendWindowForTrafficClass(FabricTrafficClassInteractive, 4); got != 4 {
t.Fatalf("interactive adaptive window = %d, want 4", got)
if got := scheduler.RecommendedParallelSendWindowForTrafficClass(FabricTrafficClassInteractive, 8); got != 8 {
t.Fatalf("interactive adaptive window = %d, want 8", got)
}
snapshot := scheduler.Snapshot()
if !snapshot.AdaptiveBackpressureActive || snapshot.AdaptiveBackpressureReason != "bulk_window_reduced_to_protect_interactive" {
t.Fatalf("adaptive snapshot = %+v", snapshot)
}
if snapshot.RecommendedParallelWindows[FabricTrafficClassBulk] != 1 || snapshot.RecommendedParallelWindows[FabricTrafficClassInteractive] != 4 {
if snapshot.RecommendedParallelWindows[FabricTrafficClassBulk] != 1 || snapshot.RecommendedParallelWindows[FabricTrafficClassInteractive] != 8 {
t.Fatalf("recommended class windows = %+v", snapshot.RecommendedParallelWindows)
}
if snapshot.TrafficClassCounts[FabricTrafficClassBulk] != 16 || snapshot.TrafficClassCounts[FabricTrafficClassInteractive] != 1 {