I’m looking for educational materials on the (manual) program optimisation process.
A recent example that I enjoyed is the Time Profiling section in the “Rust and WebAssembly” book.
Here’s what I learned from that book, and would like more examples of:
Using various profiling tools to identify potential areas of improvement
I learned about
console.time(), and how to view their results in the browser. This gave me a rough summary of where my program was spending its time. I then learned how to use
perf to view which lines of code/instructions took the most time. This was all in service of focusing my attention on the parts of the program that were too slow.
Implementing program optimisations
perf showed that a lot of time was spent in
div instructions, and the author explained why that time could be significantly decreased. In summary, most of the calls to
div didn’t change the result of the computation, and the cases that did influence the result could be replaced by branches, which would be well-predicted by the CPU. I think I’d find it really valuable to be guided through this process for a variety of different performance issues and improvements.
Measuring the impact of optimisations
The book showed how to use a benchmark comparison tool to measure the change in performance as we applied more optimisations. I enjoyed that I didn’t have to guess; if I had an idea, I could just measure the outcome.
I’m happy for this to become a sort of “brain dump” thread; post anything that comes to mind given what I’ve described.