r/cpp • • Apr 23 '26

Devirtualization and Static Polymorphism

https://david.alvarezrosa.com/posts/devirtualization-and-static-polymorphism/
81 Upvotes

36 comments sorted by

View all comments

8

u/johannes1971 Apr 23 '26

The article is based on the premise that a single additional assembly instruction causes 'underperformance in benchmarks', yet it completely fails to present any kind of performance data. I'm reminded, somehow, of the story of Don Quixote, who was also known for fighting imaginary problems.

And sure, a memory load can be the cause of some slowdown. That assumes that the data is not already in cache, or needed soon anyway. Is that a realistic assumption?

2

u/david-alvarez-rosa Apr 24 '26

Good point. Will work on objective benchmarks for the next one. Thanks for the feedback!

3

u/[deleted] Apr 24 '26 edited Apr 24 '26

[removed] — view removed comment

1

u/johannes1971 Apr 24 '26

No, it's not a reach. But we should also keep a sense of perspective about this, and statements like "calling virtual functions leads to underperformance in benchmarks" very quickly start leading a life of their own, causing people to write convoluted CRTP code when that is absolutely not necessary.