Back to Basics: Virtual Dispatch and its Alternatives - Inbal Levi - CppCon 2019
Vložit
- čas přidán 5. 05. 2024
- CppCon.org
Discussion & Comments: / cpp
Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2019
-
Back to Basics: Virtual Dispatch and its Alternatives
Code efficiency is one of the strongest features of modern C++, therefore broadly used in industries with a need for high performance, such as Real-Time or Embedded Systems.
In this talk, we will go through the search for high run-time efficiency using the dispatch mechanism.
We will start by providing tools for understanding and estimating run-time performance cost.
Next, we'll analyze a test case, and dive into some of the most fundamental components of the language such as inheritance, and templates.
We will continue by introducing implementations which produce high run-time efficiency code such as CRTP, std::variant and visitor, and use them to maximize performance.
Finally, we will do benchmarking and draw conclusions, and try to answer the question -
How can we use C++ ideally for achieving high-performance efficiency?
-
Inbal Levi
Software engineer, SolarEdge
Inbal Levi is a C++ enthusiastic, embedded software engineer with a passion for high performance.
-
Videos Filmed & Edited by Bash Films: www.BashFilms.com
*-----*
Register Now For CppCon 2022: cppcon.org/registration/
*-----* - Věda a technologie
Small note to implementation 24:00 - The implementation of std::variant is library specific. The STL of windows for example doesn't use virtual tables. It uses a switch statement instead.
The implementation of `visit` completely flew over my head.
Overall, very interesting talk, thank you. I wish this talk was a little more basic, and focused on how V-Tables worked, instead of focusing on ways not to use them.
nice
18:23 I think in =main= you actually want =FilterBright f1;= and =FilterBright f2;=, not the CRTP types.
I don't think it's correct to compare performance of compile-time polymorphism with dynamic polymorphism. They have completely different use cases. AFAIK there are only 3 ways of doing the latter: virtual function calls, std::variant and C-style structs with function pointers (or std::functions). Of those 3, the virtual function calls use least memory and result in easiest code to read and maintain.
You might have a point regarding the title (it was changed by the team to fit to Back to basics), the talk description is more informative.
It is a basic talk focusing on inheritance and runtime dispatch overhead, so the idea is to present that there are other alternatives.
I agree that the ones you've mentioned are the runtime alternatives. :)