r/ProgrammingLanguages • u/gingerbill • Sep 02 '26
CTTI is Exponential, RTTI is Linear
https://www.gingerbill.org/article/2026/09/02/ctti-is-exponential-rtti-is-linear/
0
Upvotes
r/ProgrammingLanguages • u/gingerbill • Sep 02 '26
View all comments
3
u/matthieum Sep 03 '26 edited Sep 03 '26
Doesn't this widely depend upon what information is included in RTTI?
For example, in C++, RTTI can be used to perform cross-casts via
dynamic_cast. This requires that every type encode the full hierarchy of interfaces it implements.The size of this information is linear in the number of types, and linear in the highest number of interfaces implemented by a type... but it's the product of the two, so feels quadratic-ish no?
You're missing perhaps the most important place of all: i-cache.
Bloating the i-cache with virtually (but not quite) identical copies of the same function has a run-time performance cost, due to the ensuing cache-misses which stall execution.