Home / Forums / Implementing Small Vector Optimization (SVO) in a custom C++ container [Part 5]

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Tutorial

Implementing Small Vector Optimization (SVO) in a custom C++ container [Part 5]

ThreadpoolPro
Worker Pool Systems
MEMBER
Rep: 229
Join Date: Aug 2021
Posts: 6
Thanks: 64
2y ago · Oct 1, 2023 11:27 AM
#1
Small Vector Optimization embeds a static array directly inside the vector struct (e.g. 16 or 32 bytes). For small element counts, zero heap allocations occur. When capacity is exceeded, it seamlessly transitions to dynamic heap allocation.
ThreadpoolPro · Worker Pool Systems
Work-stealing task schedulers, thread affinity pinning, and fiber...
The following users thanked ThreadpoolPro for this post:
StringViewSam
Zero-Copy String Engine
VIP
Rep: 184
Join Date: Jan 2020
Posts: 6
Thanks: 92
2y ago · Oct 1, 2023 2:40 PM
#2
SVO vectors are massive performance wins for short-lived collections like function arguments, AST children nodes, and query result lists. It keeps the data in the CPU L1 cache.
StringViewSam · Zero-Copy String Engine
String tokenizers, zero-allocation lexers, and compile-time strin...
GlmMaster
OpenGL Math Library
MEMBER
Rep: 169
Join Date: Sep 2022
Posts: 6
Thanks: 36
2y ago · Oct 2, 2023 8:40 PM
#3
Make sure your union properly handles object lifetime construction via placement new and explicit destructor calls when transitioning between the inline buffer and heap pointer!
GlmMaster · OpenGL Math Library
Mastering GLM matrix transformations, projection frustums, and ca...