Faster, Easier, Simpler Vectors
summary
Argues that std::vector can be replaced for many workloads and shows concrete implementations: 32‑bit vector, static vector, small‑buffer and stable vector that use virtual memory overcommit. Introduces primitives like append_from_capacity and uninitialized_relocate_no_overlap, a lazy‑pushback pattern, and reserve growth strategy. Provides a 145‑line reference implementation in the GitHub repo, inspects compiler‑generated assembly with Compiler Explorer, and reports small (1–5%) wins on typical sizes but up to ~30% worse for huge inputs when allocator/ABI tradeoffs aren’t tuned.
AI-written summary · about
chapters (22)
- 0:00Introduction
- 1:36Outline
- 3:04Who am I
- 5:24Design Approach
- 6:54Vectors
- 10:40Vector Interface
- 12:36Copy Assignment
- 15:37Initializer List
- 19:13Allocators
- 22:25Live Demo
- 23:32Lazy Pushback
- 24:20Guaranteed Copy Illusion
- 25:20Generic Programming
- 26:15Pushback
- 30:39Move vs relocate
- 32:06trivial relocation
- 34:52trivial relocatable
- 37:40allocation
- 39:37assembly output
- 43:18static vector
- 46:50use cases
- 54:26programming language
related talks
01h 00mCache Friendly C++
01h 00mMoving Faster: Everyday efficiency in modern C++
01h 05mFast and small C++ - When efficiency matters
58mC++ Performance and Optimisation
12mVectorCDC: Accelerating Data Deduplication with Vector Instructions
56m“High Performance Code 201: Hybrid Data Structures"
01h 01mRefresher on Containers, Algorithms and Performance in C++
01h 03mFast and Small C++ - When Efficiency Matters
