Batching in Go

The batching of data or computation amortizing a fixed cost over multiple units — is a very common pattern in many computers systems. It’s particularly prevalent in networking and CPU memory accesses.

But the implementation of batching includes many subtleties — in particular when to wait for more data, and when to transmit what you have.

I came across a really nice batching implementation in Go, written by Caleb Spare. Caleb’s implementation wraps up both transmitting after a period without receiving more data, as well as ensuring that the receiver can accept any data to be sent — it’s a very nice pattern. So be sure to check it out if you’re looking to batch your processing in the Go language.

Leave a Reply

Your email address will not be published. Required fields are marked *