coalesceDuration picks the coalesce window for the current drain. Under high session fan-out we shrink the window: the next batch fills within a few ms anyway, and 25ms of extra accumulation per response just adds tail latency. Large batches (already half-full or more) keep the full 25ms because the
(currentFrames int)
| 472 | // tail latency. Large batches (already half-full or more) keep the full |
| 473 | // 25ms because they are bulk-dominant and benefit from extra throughput. |
| 474 | func (s *Server) coalesceDuration(currentFrames int) time.Duration { |
| 475 | s.mu.Lock() |
| 476 | sessionCount := len(s.sessions) |
| 477 | s.mu.Unlock() |
| 478 | if sessionCount >= busySessionThreshold && currentFrames < maxDrainFramesPerBatch/2 { |
| 479 | return coalesceWindowBusy |
| 480 | } |
| 481 | return coalesceWindow |
| 482 | } |
| 483 | |
| 484 | // routeIncoming routes one incoming frame to its session, creating the session |
| 485 | // (and dialing upstream) if this is a SYN. owner is the clientID of the |