Runtime Polymorphism: Back to the Basics
summary
Explores concrete alternatives to inheritance by implementing a policy-based type erasure (the Dyno library) that supports remote storage, small‑buffer (16‑byte) SBO and local storage and lets the Vtable be remote, partially inlined, or fully inlined. Builds hand‑rolled and Dyno versions, runs microbenchmarks showing heap allocations dominate cost and that hitting the 16‑byte SBO cutoff drops creation cost dramatically; finds Vtable inlining increases object size and often slows calls, so tradeoffs depend on storage, dispatch placement and measured workloads.
AI-written summary · about
chapters (19)
- 0:00Introduction to polymorphism
- 2:55Drawbacks of inheritance
- 6:15Designing a better alternative
- 10:17Implementing manual erasure
- 14:03Using the 'dyno' library
- 16:52Small buffer optimization
- 21:46Performance benchmarks
- 23:55Fixed-size storage policy
- 27:39More benchmarks and analysis
- 32:14Non-owning storage
- 35:08Shared storage
- 36:32Real-world type erasure
- 40:29Inlining the v-table
- 44:17Partial v-table inlining
- 46:10Assembly and optimization
- 49:12Iterator optimization case
- 51:55The future of polymorphism
- 55:30Summary and conclusion
- 57:33Q&A session
related talks
01h 35mRuntime Polymorphism: Back to the Basics
01h 00mDynamic Polymorphism with Metaclasses and Code Injection
01h 23mRethink Polymorphism in C++
49mPolymorphism != Virtual: Easy, Flexible Runtime Polymorphism Without Inheritance
55mBreaking Dependencies: Type Erasure - The Implementation Details
01h 00mBack to Basics: Object-Oriented Programming
55mHow to "OO" in C++
01h 31mWhen Abstractions Fix Too Much - Towards Flexible Library Design
