Very slow performance in float4x4.TRS

Just discovered this weird reading while deep-profiling a surprising drop in performance:

356 calls to math.float3x3() should not take 7.72ms. Sure, some of the time is because I’m running the deep profiler, but the slowdown is real and present even when not profiling at all.

There are situations where I perform many more float4x4.TRS calls, and performance there is so bad that the editor stops responding (although it keeps running the game), so I can’t pause the game and screenshot the profiler to show how much time is spent in math.float3x3().

I’m running Unity 2019.4.1f1, using Burst version 1.2.3.

The deep-profiler isn’t going to show you what is happening in Burst, which means you aren’t using Burst in this context and that probably is partly responsible for the slowness. Another factor to the slowness could be the memory access pattern. Without seeing code or performance numbers without deep profiling, it is hard to say. Using Profiling.Begin/EndSample around a loop is typically much better for getting real numbers.

I’ll give that a shot, thanks! You’re right, this is single-threaded code and I don’t even have to use float4x4.TRS in this case, but it still made me curious.