Re:Beating C with 70 lines of Go
by ajeetdsouza on Wednesday November 20, 2019 @03:09PM
(#21587936)
This is not true, see my comment here: https://news.ycombinator.com/edit?id=21587907
Take the Darwin version linked from your site. Run perf record wc thefile.txt. Then run perf report and you will see iswspace in the call graph.
As I show in [1], removing this call and replacing it by a character match, gives a speedup of almost 2x.
This can be easily shown, by counting words and lines using wc separately. Word counting decodes characters (to find non-ASCII whitespace that may separate words), whereas line counting just looks for ASCII line separators:
So, without character decoding, looking at every byte is ~15 times faster. So, if you'd compile wc without multibyte character support (which would be a fair comparison), it would probably beat Go without any parallelization.