Re:Experience converting a mathematical software package to ...
by ttoinou on Tuesday July 01, 2025 @03:26PM
(#44437223)
Why does it ruin runtime performance ? The code should be almost the same
[ Parent
| on HN ]
Re:Experience converting a mathematical software package to ...
by vblanco on Tuesday July 01, 2025 @03:34PM
(#44437281)
Because you now need to go through virtual calls on functions that dont really need to be virtual, which means the possible cache miss from loading the virtual function from vtable, and then the impossibility of them being inlined. For example they have a ITexture interface with a function like virtual GetSize(). If it wasnt all through virtuals, that size would just be a vec2 in the class and then its a simple load that gets inlined.
Re:Experience converting a mathematical software package to ...
by ttoinou on Tuesday July 01, 2025 @03:37PM
(#44437305)
Ah yes this kind of interface ok indeed this doesn't seem like a useful layer when running the program. Maybe the compilers could optimize this though
Re:Experience converting a mathematical software package to ...
by jeremiahar on Tuesday July 01, 2025 @08:45PM
(#44439278)
In my experience, as long as there's only a single implementation, devirtualization works well, and can even inline the functions. But you need to pass something along the lines of "-fwhole-program-vtables -fstrict-vtable-pointer" + LTO. Of course the vtable pointer is still present in the object. So I personally only use the aforementioned "thin headers" at a system level (IRenderer), rather than for each individual object (ITexture).
Re:Experience converting a mathematical software package to ...
by drysine on Wednesday July 02, 2025 @05:33AM
(#44441694)
They can sometimes
https://quuxplusone.github.io/blog/2021/02/15/devirtualizati...