Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kgo: broadcast batch finishes in one big blast
Previously, we would broadcast after every individual record finished in a batch. If we produced 5000 records concurrently but only allowed 1000 in flight, we would first send a few large batches, and then once they started finishing, we would: * Finish a record * Wake up a waiting record * That record would race into producing * The producing wouldn't linger even if we wanted to, because other records are blocked * That record would be produced alone in one batch immediately * Goto start This forced unnecessary synchronization and caused things to produce slowly. By doing one broadcast at the end of a batch, we actually give more "space" for the client to buffer before waking up everything waiting. The first goroutine awoken will still produce a small batch, _but_ we will reach a point where the client is buffering larger batches. Overall, this speeds things up for a niche case and is not detrimental in any way to the non-niche case.
- Loading branch information