Re:What it feels like when Rust saves your bacon
by heisjustsosmart on Saturday June 25, 2022 @09:47AM
(#31875275)
Virtual methods are about dispatch tables (which are built at compile time) and have nothing to do with paging. Nothing. At all.
This has traditionally been managed with CRTP, tagged unions, etc with some scaffolding to make it convenient and compliant with strict aliasing rules. Ideally, almost all of the dynamic polymorphism is pulled up to the level of the page types, an opaque blob of I/O friendly complex data structure, minimizing the amount you have to do. It is also important to note that JIT-ing has replaced many of the use cases for dynamic dispatch e.g. adding user-defined schemas at runtime.
None of which may apply to your use case. Some things inherently require an unfortunate amount of dynamic dispatch.