Recipes for reducing allocations by C++ containers
It is well known that allocations can have a significant negative impact on the runtime performance of software. Frequently, these memory requests are made by containers (standard ones or otherwise). But the actual allocations might not be easily identifiable, and the options to avoid them aren't obvious. In this talk, we will go through a number of comprehensible recipes to address these issues. We will start with the most basic
std::vector<T>::reserve, cover container choices and using the right constructors. Then, different forms of scope promotion are discussed, before we cover view types and two hands-on examples with
pmr allocators. Recipes are presented with a discussion of up- and downsides, benchmarks, and techniques to measure and diagnose allocation behaviour.
Lukas is a civil engineer who stuck with Fortran77 during his PhD and started a C++ side project to alleviate his frustration. This worked out; today, he develops software for Oxbotica, a robotics spinoff working on autonomous vehicles. Lukas likes reading, brass music, Newton mechanics and his family.