Skip to content

Latest commit

 

History

History
368 lines (229 loc) · 17.1 KB

File metadata and controls

368 lines (229 loc) · 17.1 KB

Optimization

Table of contents


Introduction

🎥

Performance and optimization

See also Optimizations – Compilers.

🔗

🎥

📖

Branch prediction

🔗

[[likely]] / [[unlikely]] attributes

These attributes allow the compiler to optimize for the case where paths of execution are more or less likely than any alternative path of execution.

likely / unlikely Linux kernel macros

Memory

🔗

Memory copying

🔗

Memory allocation

See also Allocators – The standard library and proposals.

🔗

🎥

Memory relocation

🔗

🎥

Memory access

Nested std::vectors

Aliasing

See also Type-punning – Core language.

🎥

Floating-point arithmetic

🔗

Integral arithmetic

Integral multiplication

Integral division

🔗

Signed and unsigned types

🎥

Empty base class optimization (EBO)

Empty base class optimization allows the size of an empty base subobject to be zero. Empty base optimization is required for standard layout types.

struct Empty {};
static_assert(sizeof(Empty) >= 1);

struct Derived : Empty {
    T i;
};
static_assert(sizeof(Derived) == sizeof(T));

🔗

🎥

📖

Return value optimization and copy elision

🔗

🎥

Tail call optimization

🔗

Virtual functions

🎥

Devirtualization

🔗

Undefined behavior

🔗

🎥

Infinite loops

See also Infinite loop – Patterns, idioms, and design principles.

🎥

Strict aliasing rule

See Type-punning – Core language.


Benchmarking

🔗


Profiling

🎥


Interaction with hardware

🎥