C++ Performance and Optimisation

C++ NDC TechTown

This two-day course is designed to give developers an appreciation of how to achieve better performance from their C++ code. It covers a wide range of topics from how modern machines work through how best to lay out data, which containers to use, and when multi-threading is helpful.

This course is based on Linux tools – there is no equivalent Windows-based course. An online Linux environment can be provided if necessary.

Day 1 – morning

  • Measurement and big-O notation
  • Factors that drive performance in modern machines
  • Memory hierarchy and caching
  • Function inlining and virtuals
  • Branch prediction
  • Data layout
  • Vectorisation
  • Compiler optimisations

Day 1 – afternoon

  • Value and move semantics, Rule of 3/5/zero
  • RVO, lifetime management, RAII, wrappers
  • Unique and shared pointers
  • Emplacement semantics

Day 2 – morning

  • STL containers and other containers (flat sets/maps)
  • Performance, memory, insertion and search
  • Dense linear access
  • Read and write amplification
  • Six questions about data
  • Operational profile
  • Performance tradeoffs

Day 2 - afternoon

  • Alternative approaches to string handling
  • Dos and don'ts of multithreaded programming
  • Key takeaway points

Suitable for

This course is suitable for programmers with a basic knowledge of C++ and the STL.

Prerequisites

Knowledge of C++, preferably C++11.

Computer setup

Access to a Linux or Mac system (a suitable online system can be provided if required). Minimum compiler versions: g++ 4.9, clang 3.6.

    Tid

    09:00 - 17:00