I/O is no longer the bottleneck?
Nov 27th, 2022
Recently Ben Hoyt published a blog post claiming that contrary to popular belief, I/O is not the bottleneck in typical programming interview problems such as counting word frequencies from a stream. Sequential read speed has come a long way, while CPU speed has stagnated.
Sequential reads are indeed incredibly fast. Using the same method as linked in Ben Hoyt's post, I'm getting 1.6 GB/s sequential reads on a cold cache, and 12.8 GB/s on a warm cache (best of five).
But it should be possible to count word frequencies at a speed of 1.6 GB/s even on a single thread, right?
(For the impatient: code is available on GitHub.)
The optimized C implementation
Ben Hoyt's blog refers to an earlier post which includes a faster C version of the word frequency counter. I compiled optimized.c with GCC 12, using -O3 -march=native flags, and ran it on the 425MB input file (100 copies of the King James Version of the Bible).
The result was surprisingly bad:
$ time ./optimized < bible-100.txt > /dev/null real 0m1.525s user 0m1.477s sys 0m0.048s
... continue reading