forked from quic-go/quic-go
Merge pull request #504 from lucas-clemente/fix-499
enable flow control window auto-tuning for the first WindowUpdate
This commit is contained in:
@@ -119,6 +119,11 @@ func (c *flowController) IncrementHighestReceived(increment protocol.ByteCount)
|
||||
}
|
||||
|
||||
func (c *flowController) AddBytesRead(n protocol.ByteCount) {
|
||||
// pretend we sent a WindowUpdate when reading the first byte
|
||||
// this way auto-tuning of the window increment already works for the first WindowUpdate
|
||||
if c.bytesRead == 0 {
|
||||
c.lastWindowUpdateTime = time.Now()
|
||||
}
|
||||
c.bytesRead += n
|
||||
}
|
||||
|
||||
|
||||
@@ -316,7 +316,7 @@ var _ = Describe("Flow controller", func() {
|
||||
|
||||
It("returns the new increment when updating the window", func() {
|
||||
setRtt(10 * time.Millisecond)
|
||||
controller.bytesRead = 9900 // receive window is 10000
|
||||
controller.AddBytesRead(9900) // receive window is 10000
|
||||
controller.lastWindowUpdateTime = time.Now().Add(-19 * time.Millisecond)
|
||||
necessary, newIncrement, offset := controller.MaybeUpdateWindow()
|
||||
Expect(necessary).To(BeTrue())
|
||||
@@ -325,9 +325,26 @@ var _ = Describe("Flow controller", func() {
|
||||
Expect(offset).To(Equal(protocol.ByteCount(9900 + newIncrement)))
|
||||
})
|
||||
|
||||
It("increases the increment sent in the first WindowUpdate, if data is read fast enough", func() {
|
||||
setRtt(10 * time.Millisecond)
|
||||
controller.AddBytesRead(9900)
|
||||
necessary, newIncrement, _ := controller.MaybeUpdateWindow()
|
||||
Expect(necessary).To(BeTrue())
|
||||
Expect(newIncrement).To(Equal(2 * oldIncrement))
|
||||
})
|
||||
|
||||
It("doesn't increamse the increment sent in the first WindowUpdate, if data is read slowly", func() {
|
||||
setRtt(2 * time.Millisecond)
|
||||
controller.AddBytesRead(9900)
|
||||
time.Sleep(5 * time.Millisecond) // more than 2x RTT
|
||||
necessary, newIncrement, _ := controller.MaybeUpdateWindow()
|
||||
Expect(necessary).To(BeTrue())
|
||||
Expect(newIncrement).To(BeZero())
|
||||
})
|
||||
|
||||
It("only returns the increment if it was increased", func() {
|
||||
setRtt(10 * time.Millisecond)
|
||||
controller.bytesRead = 9900 // receive window is 10000
|
||||
controller.AddBytesRead(9900) // receive window is 10000
|
||||
controller.lastWindowUpdateTime = time.Now().Add(-21 * time.Millisecond)
|
||||
necessary, newIncrement, offset := controller.MaybeUpdateWindow()
|
||||
Expect(necessary).To(BeTrue())
|
||||
|
||||
Reference in New Issue
Block a user