fix: throughput bug where maxWireFPS=120 capped send rate 32x too low

This commit is contained in:
zarazaex69
2026-05-07 22:12:46 +03:00
parent 0fed01fd1b
commit fb456c3ebe
2 changed files with 6 additions and 11 deletions

View File

@@ -52,7 +52,6 @@ const (
outboundQueueSize = 1024
inboundQueueSize = 1024
canSendHighWatermark = 90 // percent
maxWireFPS = 120
keepaliveIdlePeriod = 100 * time.Millisecond
)
@@ -357,15 +356,10 @@ func (p *streamTransport) writerLoop() {
}
func (p *streamTransport) sampleInterval() time.Duration {
sampleInterval := p.frameInterval
if p.batchSize > 1 {
sampleInterval = p.frameInterval / time.Duration(p.batchSize)
return p.frameInterval / time.Duration(p.batchSize)
}
minInterval := time.Second / maxWireFPS
if sampleInterval < minInterval {
return minInterval
}
return sampleInterval
return p.frameInterval
}
func (p *streamTransport) resetKCP() {

View File

@@ -20,13 +20,14 @@ type fakeVideoSession struct {
err error
}
func TestSampleIntervalIsCappedForLargeBatch(t *testing.T) {
func TestSampleIntervalWithBatch(t *testing.T) {
tr := &streamTransport{
frameInterval: time.Second / 60,
batchSize: 64,
}
if got := tr.sampleInterval(); got != time.Second/maxWireFPS {
t.Fatalf("sampleInterval() = %v, want %v", got, time.Second/maxWireFPS)
want := time.Second / 60 / 64
if got := tr.sampleInterval(); got != want {
t.Fatalf("sampleInterval() = %v, want %v", got, want)
}
tr.batchSize = 1