-
Hi, thank you for the great work on this library! I’ve been exploring proxy and noticed the claim that: However, I’m curious about how proxy compares in terms of performance and overhead to static dispatch techniques like CRTP (Curiously Recurring Template Pattern), which are also known for avoiding virtual dispatch and enabling inlining. Specifically: Are there any benchmarks comparing proxy to CRTP-style dispatch? In cases where object lifetimes are simple and predictable, would CRTP still outperform proxy? Or is proxy competitive even in such scenarios, thanks to its internal optimizations? I’d love to understand the trade-offs more clearly—both in terms of runtime performance and flexibility. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @kaixiongg, thanks for asking. It's a great one! There is currently no benchmark comparing proxy with CRTP, because CRTP is not a type-erasure technique. While CRTP enables polymorphic behavior at compile time, it doesn't abstract away concrete types at runtime. This means CRTP can't manage the lifetime of heterogeneous objects in a unified way, which is a core capability of type-erasure. So discussing lifetime management performance in the context of CRTP is not meaningful. Regarding invocation performance, CRTP typically results in direct function calls that the compiler can inline, making them very efficient. In contrast, |
Beta Was this translation helpful? Give feedback.
Hi @kaixiongg, thanks for asking. It's a great one!
There is currently no benchmark comparing proxy with CRTP, because CRTP is not a type-erasure technique. While CRTP enables polymorphic behavior at compile time, it doesn't abstract away concrete types at runtime. This means CRTP can't manage the lifetime of heterogeneous objects in a unified way, which is a core capability of type-erasure. So discussing lifetime management performance in the context of CRTP is not meaningful.
Regarding invocation performance, CRTP typically results in direct function calls that the compiler can inline, making them very efficient. In contrast,
proxy
introduces an additional layer of indirection due to it…