C++ and the Fight Between Elves and Orcs
summary
Live-coding of a custom allocation strategy: a type-local member operator new/delete and an arena-based allocator that preallocates size_of(Orc)×N (example N = 10,000 or suggested 10 million) into a contiguous buffer; Orcs are 24 bytes each. Measured baseline using vendor new ≈ 492,000 μs to allocate N objects and ≈ 220 μs to destroy them; the arena version returns allocations in constant time and nearly zero work on delete, yielding orders-of-magnitude speedup and deterministic constant-time behavior. Caveats: no array forms, overflow checks, and derived-class size/slicing pitfalls.
AI-written summary · about
chapters (14)
- 0:00Introduction
- 1:45New and Delete
- 18:39Vector
- 19:54Standard Function
- 22:09The Fight
- 25:14Arena Based Allocation
- 26:25Arena Template
- 28:39Memory Allocation
- 34:39Using Knowledge
- 37:39Summary
- 44:04Things to be careful of
- 46:00Inheritance issues
- 47:43What happens when new fails
- 49:31Placement Unit
related talks
01h 41mLocal (arena) Memory Allocators
01h 01mRecipes for Reducing Allocations by C++ Containers
01h 01mGetting Allocators out of Our Way
44mC++ Performance and Optimisation
06mLightning Talk: Speeding up code with C++17 Polymorphic Memory Resources
01h 11mDynamic Memory Allocation Challenges in C++ Safety Critical Systems
01h 01mAllocators: The Good Parts
55mBreaking Dependencies: Type Erasure - The Implementation Details
