fix: close stream adaptive gaps and switch notify to stario v0.1.1

- make stream fast path honor adaptive soft payload limits end-to-end
  - split oversized fast-stream payloads into sequential frames before batching
  - use adaptive soft cap when encoding stream batch payloads
  - move timeout-like error detection into production code for adaptive tx
  - tune notify FrameReader read size explicitly to avoid throughput regression
  - drop local stario replace and depend on released b612.me/stario v0.1.1
This commit is contained in:
2026-04-18 16:05:57 +08:00
parent 4f760f2807
commit f038a89771
76 changed files with 12656 additions and 906 deletions
+48
View File
@@ -105,3 +105,51 @@ func TestStreamFlowControllerAdmitsRequestsFIFO(t *testing.T) {
t.Fatalf("second admitted request = %d, want 3", second)
}
}
func TestStreamFlowControllerTryAcquireDoesNotBypassQueuedWaiter(t *testing.T) {
controller := newStreamFlowController(streamConfig{
ChunkSize: 4,
InboundQueueLimit: 1,
InboundBufferedBytesLimit: 4,
OutboundWindowBytes: 4,
OutboundMaxInFlightChunks: 1,
})
releaseFirst, err := controller.acquire(context.Background(), 4)
if err != nil {
t.Fatalf("first acquire failed: %v", err)
}
defer releaseFirst()
waiterReady := make(chan struct{})
waiterAcquired := make(chan func(), 1)
go func() {
close(waiterReady)
releaseSecond, err := controller.acquire(context.Background(), 4)
if err != nil {
t.Errorf("waiter acquire failed: %v", err)
return
}
waiterAcquired <- releaseSecond
}()
<-waiterReady
time.Sleep(20 * time.Millisecond)
if controller.tryAcquire(4) {
t.Fatal("tryAcquire should not bypass queued waiter")
}
releaseFirst()
var releaseSecond func()
select {
case releaseSecond = <-waiterAcquired:
case <-time.After(time.Second):
t.Fatal("timed out waiting for queued waiter to acquire")
}
if releaseSecond == nil {
t.Fatal("queued waiter returned nil release func")
}
releaseSecond()
}