Hacker News new | ask | show | jobs
by bytepoet 426 days ago
The blog post is really good. I see that there's a follow-up piece 'The Fifth Kind of Optimisation' about parallelism.

Something that I'd like to add is that it's helpful to understand the optimization capabilities of our compiler. Ideally, we would like to write program that doesn't have what are called 'optimization-blockers' - these make it hard for the compiler to generate optimized executables.

I like the pointer to the blog on accidentally quadratic implementations. I find that the following pattern is often a landmine:

for (int i = 0; i < strlen(s); i++) // code in loop

strlen(s) gets computed every iteration, incurring O(n) time.

Finally, being aware that I/O latencies are major source of bottlenecks leads to nice optimizations. One advantage of multiple threads is that they can sometimes hide the I/O latency. In general, writing programs with good memory locality is one of the better levers for optimization.