FastDynamicCast icon indicating copy to clipboard operation
FastDynamicCast copied to clipboard

Comparison to memoized_cast

Open solodon4 opened this issue 8 years ago • 3 comments

Can you elaborate on how fast dynamic cast compares to memoized_cast of Mach7? You can find an overview of it in section 5.5 here. Also it would be great if you can include memoized_cast in your performance comparisons.

A different name would probably help too as Gibbs and Stroustrup had a paper Fast Dynamic Casting that exploits a different idea for improving speed of dynamic_cast.

solodon4 avatar Dec 14 '16 19:12 solodon4

I would also like to suggest running tests on class hierarchies from COU project. It contains large real-world class hierarchies that were written by humans. That benchmark has already been used in a number of research projects on improving the speed of subtype checking and subtype casting and I've included there parser and a C++ printer to help with benchmarking C++ improvements.

solodon4 avatar Dec 14 '16 20:12 solodon4

From a first look at the source of memoized cast, it seems to do something similar, with the exception that it uses a map for offset lookup, which is slower than the static variables that my dynamic cast uses. However, I guess in some scenarios where you have a lot of failed casts or cache misses, I guess a map could be faster. Also, when using multithreading, my fast dynamic cast uses thread local variables, where as the mach7 implementation (Please correct me if I am wrong) seems to use atomics.

I will perform a performance comparison and post results when I'm done with it.

I agree that the name is not pretty unique, but I simply wasn't able to come up with a better one. Feel free to suggest one

tobspr avatar Dec 14 '16 21:12 tobspr

Can you elaborate on how fast dynamic cast compares to memoized_cast of Mach7? You can find an overview of it in section 5.5 here. Also it would be great if you can include memoized_cast in your performance comparisons.

A different name would probably help too as Gibbs and Stroustrup had a paper Fast Dynamic Casting that exploits a different idea for improving speed of dynamic_cast.

The code for memoized_cast seems to be much more complicated. I don't even have the ability to extract it from the mach7 project and use it alone. Of course memoized_cast should be cross-platform.

sgf avatar Aug 15 '20 08:08 sgf