~/talk

C++ Run-Time Optimizations for Compile-Time Reflection

Talkat C++ on Sea 2024 · 2024-07-02..07-05· [compilers-and-language-design]
links:none on file
slides:none on file

C++26 static reflection plus C++20 tricks get applied to enum_to_string and string_to_enum, with concrete code paths and benchmarks. LLVM MCA guides decisions between if/else, nested switch/jump tables, SIMD vector compares and a BMI2 pext bit extract based lookup that builds a compile‑time mask and a perfect (or minimal perfect) hash table via constexpr search. Results show constant‑time register lookups and an order‑of‑magnitude speedup over naive approaches for typical enums, at the cost of heavier compile‑time work and hardware fallbacks.

AI-written summary · about

  1. 0:00C++ compile-time reflection intro
  2. 3:18Why compile-time reflection excites
  3. 7:14Reflection in C++26 operators
  4. 12:36Performance analysis with analyzer
  5. 16:51Enum to string with reflection
  6. 21:51SIMD vectorization for enum conversion
  7. 27:59Switch case generation acceleration
  8. 35:02Perfect hashing for enum to string
  9. 43:30x86 hardware-accelerated hashing
  10. 48:35Benchmarking enum conversion methods
  11. 53:00Enum conversion with compile-time hashing
  12. 56:52Minimal perfect hashing for strings
  13. 1:03:42Summary of reflection trade-offs
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.