Scott Wolchok

Recent posts

Jan 23, 2021
Inlining and Compiler OptimizationsWhy is inlining so important in C++? Clearly, it reduces function call overhead: if a function is inlined, there is no need to spend time setting up its arguments, jumping to it, creating a stack frame, and then undoing all that upon returning. More interestingly, though, inlining enables other compiler optimizations. In this article, I will show examples of constant propagation and loop-invariant code motion (LICM). Then, I will explain how inlining enables these optimizations to apply more widely and show an example of the consequences when that doesn’t happen.…
Jan 14, 2021
C++ Performance Trap #2: Unnecessary std::functionstd::function does what it says on the tin: it holds any callable object. For example, you can use lambdas with or without captures. It has a couple key drawbacks: It is fairly large: 32 bytes on a 64-bit system. It causes typeinfo for each used lambda to be generated. Function pointers, on the other hand, are much more limited: they can only point to free-standing functions (including lambdas with no captures!…
Jan 14, 2021
C++ Performance Trap #1: Constant-size std::vectorC++ Performance Traps Series Introduction The C++ standard library has many classes and functions that are easy to use and relatively safe. However, in situations where performance and efficiency really matter, straightforward use of the standard library may not always be the best choice. This post is the first in a series that will catalogue some of those opportunities for improvement. It is meant to be accessible to people who are not C++ gurus or language lawyers.…
Jan 14, 2021
How This Site Is MadeTLDR: Hugo, GitHub, Netlify. Putting writing on a website in 2021 is surprisingly pleasant, despite a few glitches. I wanted to have a plain old static site. I can write raw HTML well enough, and I knew about Bootstrap, but that still seemed like too much work. Instead, I looked at a couple overviews of static site generators, and I ended up picking Hugo as the one most fitting my sensibilities.…