Update deque and friends. (#3276)

This commit is contained in:
Raja Subramanian
2024-12-20 07:16:14 +05:30
committed by GitHub
parent 36338bab5c
commit c8b644934f
9 changed files with 61 additions and 49 deletions
+1 -1
View File
@@ -62,7 +62,7 @@ func NewPublicationMonitor(params PublicationMonitorParams) *PublicationMonitor
params: params,
isConnected: params.IsPeerConnectionConnected,
}
p.desiredPublishes.SetMinCapacity(2)
p.desiredPublishes.SetBaseCap(4)
return p
}
+1 -1
View File
@@ -153,7 +153,7 @@ func NewBuffer(ssrc uint32, maxVideoPkts, maxAudioPkts int) *Buffer {
logger: l.WithComponent(sutils.ComponentPub).WithComponent(sutils.ComponentSFU),
}
b.readCond = sync.NewCond(&b.RWMutex)
b.extPackets.SetMinCapacity(7)
b.extPackets.SetBaseCap(128)
return b
}
+1 -1
View File
@@ -157,7 +157,7 @@ func NewProber(params ProberParams) *Prober {
p := &Prober{
params: params,
}
p.clusters.SetMinCapacity(2)
p.clusters.SetBaseCap(2)
return p
}
+2 -2
View File
@@ -20,7 +20,7 @@ type BitrateCalculator struct {
windowDuration time.Duration
duration time.Duration
windows *deque.Deque[bitrateWindow]
windows deque.Deque[bitrateWindow]
active bitrateWindow
bytes int
@@ -37,10 +37,10 @@ func NewBitrateCalculator(duration time.Duration, window time.Duration) *Bitrate
c := &BitrateCalculator{
duration: duration,
windowDuration: window,
windows: deque.New[bitrateWindow](windowCnt+1, windowCnt+1),
start: now,
active: bitrateWindow{start: now},
}
c.windows.SetBaseCap(windowCnt + 1)
return c
}
+1 -1
View File
@@ -47,7 +47,7 @@ func NewLeakyBucket(logger logger.Logger, bwe bwe.BWE, interval time.Duration, b
interval: interval,
bitrate: bitrate,
}
l.packets.SetMinCapacity(9)
l.packets.SetBaseCap(512)
go l.sendWorker()
return l
+1 -1
View File
@@ -40,7 +40,7 @@ func NewNoQueue(logger logger.Logger, bwe bwe.BWE) *NoQueue {
logger: logger,
wake: make(chan struct{}, 1),
}
n.packets.SetMinCapacity(9)
n.packets.SetBaseCap(512)
go n.sendWorker()
return n
+3 -3
View File
@@ -15,7 +15,6 @@
package utils
import (
"math/bits"
"sync"
"github.com/gammazero/deque"
@@ -81,12 +80,13 @@ type opsQueueBase[T opsQueueItem] struct {
}
func newOpsQueueBase[T opsQueueItem](params OpsQueueParams) *opsQueueBase[T] {
return &opsQueueBase[T]{
o := &opsQueueBase[T]{
params: params,
ops: *deque.New[T](min(bits.Len64(uint64(params.MinSize-1)), 7)),
wake: make(chan struct{}, 1),
doneChan: make(chan struct{}),
}
o.ops.SetBaseCap(int(min(params.MinSize, 128)))
return o
}
func (oq *opsQueueBase[T]) Start() {