Easyperf
easyperf.net · Personal blog · on HN since 2019
Denis Bakhvalov writes about low-level performance analysis and tuning, including benchmarking, CPU microarchitecture, and profiling tools like Linux perf.
What HN saysCommenters recommend it as a consistently strong blog and starting point for performance work, and also point to the author's performance book.
36HN people shared it
12linked it in comments
52stories submitted
602story points
10 months agolast shared
2019people per year2026
Most-shared posts
- 1Performance Benefits of Using Huge Pages for Code6 people · 45 points · first shared 2022 · 1 comments on HN
- 2How to get consistent results when benchmarking on Linux?5 people · 113 points · first shared 2019 · 38 comments on HN
- 3Visualizing Performance-Critical Dependency Chains3 people · 5 points · first shared 2022 · discussion on HN
- 4HW and SW Rules of Thumb3 people · 4 points · first shared 2020 · discussion on HN
- 5Performance analysis and tuning challenge #63 people · 2 points · first shared 2022 · discussion on HN
- 6Notes3 people · first shared 2019
- 7Precise timing of machine code with Linux perf2 people · 118 points · first shared 2019 · 8 comments on HN
- 8Performance Analysis of Multithreaded Applications2 people · 43 points · first shared 2019 · 1 comments on HN
- 9Enhance Performance Analysis with Intel Processor Trace2 people · 4 points · first shared 2019 · discussion on HN
- 10Four Cornerstones of CPU Performance2 people · 4 points · first shared 2022 · discussion on HN
- 11Detect False Sharing with Data Address Profiling2 people · 3 points · first shared 2019 · discussion on HN
- 12Intel Processor Trace – Part 2: Better Debugging Experience2 people · 3 points · first shared 2019 · discussion on HN
- 13Machine Programming: What if computers would program themselves?2 people · 3 points · first shared 2021 · discussion on HN
- 14Performance analysis and tuning challenge #42 people · 3 points · first shared 2021 · discussion on HN
- 15Benchmarking: Compare measurements and check which is faster2 people · 3 points · first shared 2019 · discussion on HN
What HN people wrote when they linked it
tadkar · 2023-11-30
This is a great blog to give you things to get started. https://easyperf.net/
As with all things, practice is an essential part of improving!
Then, there's learning from some real achievements. Fast inverse square root, or the 55GB/s Fizzbuzz example: https://codegolf.stackexchange.com/questions/215216/high-throughput-fi…
anonymoushn · 2024-06-14
Great post! There was a contest for counting frequencies also in 2022, you may enjoy reading some of the submissions: https://easyperf.net/blog/2022/05/28/Performance-analysis-and-tuning-c…
matt_d · 2021-01-31
I can definitely recommend https://book.easyperf.net/perf_book
The author's blog has been consistently great throughout the years, https://easyperf.net/notes/
See also microarchitectural performance analysis tools & readings, https://github.com/MattPD/cpplinks/blob/master/performance.tools.md#mi… and "Comments on timing short code sections on Intel processors", http://sites.utexas.edu/jdm4372/2018/07/23/comments-on-timing-short-co…
nkurz · 2019-05-03
Agner Fog's optimization guide is worth a very close reading:
https://www.agner.org/optimize/microarchitecture.pdf
If you want smaller chunks, Denis Bakhvalov is starting to hit his stride with a nice series of blog posts: https://easyperf.net/notes/
If that's not enough, Ingve (who submitted this) has made literally thousands of submissions, and a surprising number are excellent articles on optimization: https://news.ycombinator.com/submitted?id=ingve
NavinF · 2023-10-01
Replacing hardware memory safety with WASM is a great idea, but FWIW you can get most of the benefits by just using hugepages. Eg, clang spends 7% of its time on TLB misses and you can get a free 5% speedup using hugectl: https://easyperf.net/blog/2022/09/01/Utilizing-Huge-Pages-For-Code
The practical solution would be to replace the MMU with a tiny one that's backwards compatible and extremely cheap in silicon area and latency. Old binaries would limp along due to translation overhead while new software would use only a couple of pages across the whole system since memory protection is done in software when the bytecode is compiled and you never need to swap to disk. New binaries would run >>7% faster. I wouldn't call this a high-level CPU tho. Most high-level CPU ideas are really stupid ones like tagging every word with a type ID that must be checked by hardware while wasting cache on something the compiler could have done.
> If you get rid of branch prediction and prefetching logic you get more space for more cores. If you hook up memory in parallel to those cores you get higher effective memory throughput and executed instructions per second.
Sounds like a GPU. Compiling normal code to run on chips like that is still an open problem and I doubt it will be solved within the next decade. We'd need AGI to rewrite code the same way humans do
> CPUs already contain trie walkers for their page tables, you might as well use that for looking up data in indexes directly.
I…
ori_b · 2025-10-27
Which, with store forwarding, can be shockingly cheap. You may not actually be hitting L1, and if you are, you're probably not hitting it synchronously.
https://easyperf.net/blog/2018/03/09/Store-forwarding
and, section 15.10 of https://www.agner.org/optimize/microarchitecture.pdf
fwsgonzo · 2023-01-04
I guess that's mostly if you are running a full operating system inside it, generally in Qemu. It doesn't have to be - could just be a program. Tiny programs running in KVM can use big pages and never cause or require any pagetable changes.
For simple workloads it can even be faster than native unless you dynamically load something that uses bigger pages for your native program, eg. https://easyperf.net/blog/2022/09/01/Utilizing-Huge-Pages-For-Code
menaerus · 2022-11-29
It can be done by manually remapping the relevant sections upon application startup.
Perhaps [1] is a good resource to start with (page nr. 7). Example code is here [2]. And [3] makes some experiments with it.
[1] https://www.kernel.org/doc/ols/2006/ols2006v2-pages-83-90.pdf
[2] https://github.com/intel/iodlr/blob/master/large_page-c/example/large_…
[3] https://easyperf.net/blog/2022/09/01/Utilizing-Huge-Pages-For-Code
sillycross · 2022-11-23
Clang/LLVM accepts (little-known but documented) flags to let you align code block using a custom alignment, though it only works at file-level. See [1].
However, I'm not sure if doing so is useful or necessary. Interpreter performance is sensitive to code layout (which affects hardware branch predictor accuracy), but I don't think there is a general way to optimize the code layout to make the branch predictor as happy as possible.
So if you changed your code alignment and saw a perf change, it's more likely caused by the random perf gain/loss due to code layout change, not because that 1-byte-alignment is better than 16-byte-alignment or vice versa.
[1] https://easyperf.net/blog/2018/01/25/Code_alignment_options_in_llvm
dendibakh · 2019-11-18
You can also visit easyperf.net (my blog). If you like Linux perf the same way I do, you will like it.
Here are some links:
- https://easyperf.net/blog/2018/08/26/Basics-of-profiling-with-perf
- https://easyperf.net/blog/2019/04/03/Precise-timing-of-machine-code-wi…
- https://easyperf.net/blog/2019/02/09/Top-Down-performance-analysis-met…
But in the end, my almost every article contains a Linux perf use case scenario.
IshKebab · 2023-09-30
I've looked into this before and there are very few tools for this. The only vaguely generic one I've found is Codespeed: https://github.com/tobami/codespeed
However it's not very good. Seems like most people just write their own custom performance monitoring tooling.
As for how you actually run it, you can get fairly low noise runtimes by running on a dedicated machine on Linux. You have to do some tricks like pinning your program to dedicated CPU cores and making sure nothing else can run on them. You can get under 1% variance that way, but in general I found you can't really get low enough variance on wall time to be useful in most cases, so instruction count is a better metric.
I think you could do better than instruction count though but it would be a research project - take all the low noise performance metrics you can measure (instruction count, branch misses etc), measure a load of wall times for different programs and different systems (core count, RAM size etc.). Feed it into some kind of ML system and that should give you a decent model to get a low noise wall time estimate.
Good tips here:
https://llvm.org/docs/Benchmarking.html
https://easyperf.net/blog/2019/08/02/Perf-measurement-environment-on-L…