Costly `FixedPointNumberTemplate<int, 8u>::getDouble() const`
Posted: Fri Jan 14, 2022 5:08 am
Greets, been having some UPS issues in a bug-heavy game (with mods like rampant, but script times are remaining sub-1.2ms consistently), the in-game timings show that the Entity Update times are (depending on what the bugs are doing) between 15 to 35ms. I took a profile of the game while it was running and nicely enough a dwarf debug section exists in the executable so I got a nice mapping for the report. What I found was that the bugs are indeed doing a lot of work, over 47% of the total average frametime by themselves across both the bugs and their spawners (both are quite heavy in surprisingly roughly equal measures). However, among a lot of the calculations there is a single function called from multiple callstacks among the profile and this function by itself across all the calls is taking up ~16.2% of the total frametime, and that is `FixedPointNumberTemplate<int, 8u>::getDouble() const`. Now among my normal programming tasks I'd first look into seeing if anything is easily optimizable within it, perhaps a different algorithm (if my hunch about what it does based on its type and name is), and secondly might look into seeing how well it could be SIMD'd or so across what calls it (if it needs to be called so often to begin with), the latter would involve looking in a lot more places and the source code isn't open, so would it instead be possible to at least get the source for the `FixedPointNumberTemplate<int, 8u>::getDouble() const` (and whatever other potentially related functions if any) to see if I can work on optimizing it any as I get time? If there are tests for it I would like to see those as well to confirm any changes else I can write some.
Also, I'm curious, do the template arguments imply it's a 4-byte/32-bit `int` sized fixed point number with 8 after-fixed-point binary digits, and does its use really help over just using a 32-bit floating point type (especially since it will lack a lot of the most useful SIMD optimizations especially after it's more easily inlined as well), or is it primarily to use integer values so as to make the simulation more easily consistent (which floats can do as well, though are indeed more difficult to do right, especially on older hardware)?
Also, I'm curious, do the template arguments imply it's a 4-byte/32-bit `int` sized fixed point number with 8 after-fixed-point binary digits, and does its use really help over just using a 32-bit floating point type (especially since it will lack a lot of the most useful SIMD optimizations especially after it's more easily inlined as well), or is it primarily to use integer values so as to make the simulation more easily consistent (which floats can do as well, though are indeed more difficult to do right, especially on older hardware)?