You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+79-53Lines changed: 79 additions & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,10 +6,10 @@
6
6
7
7
A **C++17/20 header-only** container with `std::vector` semantics, Small Buffer Optimization (SBO), and full, robust allocator support. **Truly zero external dependencies**—just copy one header file into your project.
8
8
9
-
**Performance validated** (Apple M1, N=16, -O3):
10
-
-**12.7× faster** than `std::vector` for inline operations (trivial types, size=8)
11
-
-**Within 3%**of `absl::InlinedVector`and`boost::small_vector` on heap paths
-**Only implementation** that compiles `insert`/`erase` for non-assignable types on heap
14
14
15
15
This container is a production-ready, drop-in replacement for `std::vector` in scenarios where elements are often small (e.g., `< 16`), delivering massive performance benefits by avoiding heap allocations while maintaining competitive performance for larger collections.
@@ -255,18 +255,20 @@ Invalidation rules are critical and follow `std::vector` logic *within a storage
255
255
|**Dependencies**|**None (Single Header)**| Abseil Library Base | Boost Libraries |
***Note:** Abseil's `shrink_to_fit()` was added post-LTS 2021. Older LTS versions (e.g., 2021_03_24) lack this feature. This comparison uses current master branches (as of 2025-01).
264
265
265
266
### Key Insights:
266
267
267
-
1.**Dominant Inline Performance:** For its primary use case (small, inline vectors), `lloyal` is **12.7x faster** than `std::vector` for trivial types.
268
-
2.**Competitive Heap Performance:** The "rebuild-and-swap" logic for correctness has a **negligible performance cost** (\~2-3%) in heap-based insertions.
269
-
3.**Unique Correctness Guarantee:** It is the *only* implementation to compile and run the non-assignable `insert` benchmark, proving its superior type support.
268
+
1.**Dominant Inline Performance:** For its primary use case (small, inline vectors), `lloyal` is **13.2× faster** than `std::vector` for trivial types and **23% faster** than Abseil.
269
+
2.**Winning Heap Performance:** The "rebuild-and-swap" logic is now the **fastest implementation** for heap insertions at N=128 (6169ns vs 6335ns Abseil).
270
+
3.**Zero Allocator Overhead:** Custom allocators (BenchAllocator) show **0% overhead** vs std::allocator (379ns vs 380ns), validating parent pointer architecture.
271
+
4.**Unique Correctness Guarantee:** It is the *only* implementation to compile and run the non-assignable `insert` benchmark, proving its superior type support.
-**Abseil**: `master` branch (2025-10-26, includes shrink_to_fit)
410
+
-**Boost**: `1.88.0` (Homebrew)
406
411
407
-
Full benchmark suite in `bench/` directory. Run: `cmake -B build_bench -DINLINED_VECTOR_BUILD_BENCHMARKS=ON && cmake --build build_bench && ./build_bench/bench_inlined_vector`
412
+
Full benchmark suite in `bench/` directory with allocator-specific tests. Run: `cmake -B build_bench -DINLINED_VECTOR_BUILD_BENCHMARKS=ON && cmake --build build_bench && ./build_bench/bench_inlined_vector`
408
413
409
414
### 1. Inline Performance Dominance
410
415
@@ -418,12 +423,12 @@ for (int i = 0; i < 8; ++i) vec.push_back(i);
418
423
419
424
| Implementation | Time | Speedup vs `std::vector`|
| **Non-Assignable Types** | ✅ **Only impl that works** | Correctness-critical code with `const` members |
509
-
510
-
**Bottom line:** `lloyal::InlinedVector` delivers **competitive performance** (within 3% on heap paths) while providing **unique correctness guarantees** and **zero dependencies**. The rebuild-and-swap strategy's overhead is negligible in practice, and you gain features impossible in peer implementations.
529
+
| **Inline Fill (trivial, N=8)** | **13.2× faster than std::vector** ✅ | Parsers, token buffers, hot paths |
530
+
| **Inline Fill (complex, N=8)** | 1.4× faster than std::vector | Small string collections, temporary containers |
531
+
| **Heap Insert (N=128)** | **Fastest (6169 ns)** ✅ | Large collections after growth |
| **Shrink To Fit (heap→inline)** | **Same speed as std::vector** ✅ | Memory reclamation after temp spikes |
534
+
| **Non-Assignable Types** | ✅ **Only impl that compiles** | Correctness-critical code with `const` members |
535
+
536
+
**Bottom line:** `lloyal::InlinedVector` delivers **best-in-class performance** (fastest inline trivial fills, fastest heap insertions) while providing **unique correctness guarantees** (non-assignable types, zero allocator overhead) and **zero dependencies**. The allocator-aware rebuild-and-swap strategy proves to be not just correct but also the fastest approach at scale.
0 commit comments