C++ Function Multiversioning in Windows
summary
Claim: compiler and Windows 11 loader collaborate to pick the best implementation at load time by embedding metadata and a BDD that fixes up direct calls so there is no per-call branch test or indirect-call CFI cost. Tooling: Visual C++ emits an msvc dispatch attribute and LTFS sections, linker builds a BDD and a thunk page, loader applies fixups at page fault. Numbers: memset/memcpy show up to 2x throughput differences; a prototype arm64 memcpy is ~20–30% faster and CFG overhead drops by roughly half in some benchmarks. Requires OS and toolchain support and uses thunks to avoid paging and container-density costs.
AI-written summary · about
chapters (40)
- 0:00Introduction
- 0:39Problem Space
- 2:22Indirect Calls
- 5:57State Initialization
- 6:54GCC IFUNK
- 8:02iPhone Approach
- 9:24Load Time Function Selection
- 9:57Building Blocks
- 10:58OS Capabilities
- 12:46Binary Metadata
- 14:29Binary Decision Diagram BDD
- 16:00Other Building Blocks
- 16:23Ordered Set of Criteria
- 19:29How qualifiers work
- 21:02Examples
- 24:32Qualifiers
- 26:05Ordered Map
- 27:52Combine
- 28:40Syntax
- 31:23OS Support
- 32:16Tool Chain Details
- 33:33Compiler Modifications
- 35:03Expressions
- 35:40Const Expert
- 36:21Dispatch Attributed Functions
- 37:01Symbol Table
- 37:42LTFS Map
- 38:21Linker
- 40:39Arm64 Direct Calls
- 41:46Topological Bdd
- 43:21Relocation Type
- 43:50Thunk Page
- 44:49Fixups
- 47:21Thunks
- 48:46HyperV Containers
- 51:03Demo
- 53:28Performance
- 54:24Performance on Intel
- 56:54Performance on ARM
- 59:00Control Flowguard
related talks
37mC++ as an Optimizing Assembler - a Performance Talk
58mOptimization Tips - Mo' Hustle Mo' Problems
40mAdding Functionality to Make Windows Games Run Faster on Linux
01h 05mFast and small C++ - When efficiency matters
38mAsserting Your Way to Faster Programs
55mCode Size Compiler Optimizations and Techniques for Embedded Systems
01h 00m“Want fast C++? Know your hardware!"
36mInterfaces Matter
