This is the continuation of the previous post. I would strongly recommend reading Part 1 first then continue here as the description of the program, the intent and the current state are relevant as we move forward. Iter 3 - Remove Contention Iter 3 code on Github Reading line by line from the stream and sending those over to the goroutines to be processed works, but may not be the most efficient way to process a large file.
In this blog post I’ll iterate over a simple script and refactor it each time to improve its performance. Before diving into the details I would quote a couple of well known individuals from the GO Community. “You want to write code that is optimized for correctness. Don’t make coding decisions based on what you think might perform better. You must benchmark or profile to know if code is not fast enough.