m10-performance

star 13

Mastering C++ Performance. Triggers: cache locality, heap allocation, inlining, SIMD, standard layout, string_view, reserve, pmr.

13eholder By 13eholder schedule Updated 1/25/2026

name: m10-performance description: "Mastering C++ Performance. Triggers: cache locality, heap allocation, inlining, SIMD, standard layout, string_view, reserve, pmr."

C++ Performance

Core Question

Where is the data?

  • Contiguous? (Cache friendly) → std::vector.
  • Scattered? (Cache miss) → std::list, std::map.

Thinking Prompt

  1. Count the Allocations.

    • Can they be fused? (reserve).
    • Can they be removed? (Stack / SSO).
  2. Measure, Don't Guess.

    • Use Google Benchmark or Quick-Bench.
  3. Data Layout.

    • struct padding? Reorder members largest to smallest.
    • Pointer chasing? Flatten the graph.

Quick Reference

Technique Benefit Implementation
reserve() Avoid reallocs Call before loop.
string_view No copy string Params.
std::vector Cache locality Default container.
PMR Custom alloc std::pmr::monotonic_buffer_resource.
Install via CLI
npx skills add https://github.com/13eholder/Modern-Cpp-Skills --skill m10-performance
Repository Details
star Stars 13
call_split Forks 3
navigation Branch main
article Path SKILL.md
More from Creator