Abseil C++

An open-source collection of C++ library code designed to augment the C++ standard library

  • Performance Tip of the Week #9: Optimizations past their prime
    https://abseil.io/fast/9

    Originally posted as Fast TotW #9 on June 24, 2019

    By Chris Kennelly

    Updated 2023-03-02

    Quicklink: abseil.io/fast/9

    Overview

    Optimizations don’t always age gracefully. Faster yesterday might mean slower today.

    Benchmarks citing performance on Intel Pentium 3’s or AMD Opterons may have been meaningful several years ago, but optimization equilibria, originally chosen for long-unplugged platforms, may have changed since. Let’s look at a couple examples where well-intended optimizations ultimately hurt performance in the long run.

    Popcount

    In 2008, Intel introduced the popcnt instruction to determine the number of set bits in a 32- or 64-bit integer. This is of interest for computing hamming distances and a bunch of other things. Without the instruction, we can use a slightly more complex, (...)