Highly recommended.
One small niggle to begin with. The book does not have an index. That’s a bit of a pain if you want to use the paper version as a reference. Since the PDF is available for free (when the web site works) then this is less of an issue. You can just use PDF search to find things.
This is a book about performance analysis and low level optimisations. Roughly that means that it is only relevant if you develop using ‘systems programming’ languages like C, C++, D and Rust. There is a substantial amount of content covering hardware aspects. In order to understand why some code is running fast (or slow) you need to have some understanding of how the hardware works (and how the hardware interacts with the kernel and your code). Some of the measurement techniques use features present in CPUs which is all explained in this book. The CPU architectures covered are ARM, AMD and Intel. Whilst AMD and Intel have a large degree of compatibility in their instruction sets there are some quite big differences at the level of some of the built-in performance measurement capabilities. If you are working on RISCV or some older CPU architecture then you won’t get so much out of this book.
The author used to work as a compiler dev and performance engineer at Intel and so presumably had access to a great deal of information on CPU architecture and performance tools. Consequently Intel CPUs are covered with a bit more detail than ARM and AMD. I thought that he did a decent job to cover aspects of all three. Prior to reading this book, I had used several of the tools presented. I was pleasantly surprised by how much I still had to learn. There were several tools that I had never heard of, and quite a few that clearly I hadn’t understood well when I tried to use them. I should now be able to go back and use them better. Also, somewhat frustratingly, Bakhvalov also describes all of the latest and greatest CPU and tool features. At home I have a machine with a recent AMD CPU but nothing with a recent Intel CPU. At work we use servers with a Linux 4.18 kernel. That means that I can’t play easily with a lot of the tools described in this book.
Alongside the book there is a ‘Performance Ninja’ set of exercises. I haven’t yet worked through these, but doing so is on my to-do list. They do look quite good, as though they were developer for giving a performance engineering training course.
I really enjoyed reading this book, I’d say it’s the best computer book that I’ve read in the past 2 or 3 years. If you work in a domain where performance matters then you should get a copy of this book (and since the PDF is available for free, why not?).
Website: https://products.easyperf.net/perf-book-2 (you should be able to build the PDF from this, not accessible at time of editing).
Code Site: https://github.com/dendibakh/perf-ninja
Free PDF: https://products.easyperf.net/perf-book-2 (not accessible at the time of writing or editing).
Amazon Website: https://www.amazon.com/Performance-Analysis-Tuning-Modern-CPUs/dp/B0DMVQ1QDD










