You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
there is no need to indirectly create a copy of parameters in most cases. using in can drastically improve performance for several methods and operators.
for example changing float4 multiply to
public static float4 operator * (in float4 lhs, in float4 rhs) { return new float4 (lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z, lhs.w * rhs.w); }
results in a massive performance improvement in .Net 5 (hopefully similar in Mono) ~3.1 ns vs ~0.1 ns (intel 7th gen)
burst might do that already internally but it could finally make this library faster than the built in Vector3/4/... outside of Burst
Thanks for the report. This is something I'd like to do in a future version of Mathematics because without it, as you say, performance can be quite poor without Burst. The main hurdle right now is ensuring that any usages of in doesn't break Burst compilation.
I have only seen poor performance from in for simple methods in the current Mono runtime.
Burst does (luckily) not do that internally - it rather inlines the function itself. The in keyword converts the following parameter to a pointer to that type. Compilers get very suspicious when that is the case, especially when there are multiple pointers to the same type as function arguments. They usually don't inline these functions to be conservative, which is definitely the case with the current runtime.
there is no need to indirectly create a copy of parameters in most cases. using
in
can drastically improve performance for several methods and operators.for example changing float4 multiply to
results in a massive performance improvement in .Net 5 (hopefully similar in Mono) ~3.1 ns vs ~0.1 ns (intel 7th gen)
burst might do that already internally but it could finally make this library faster than the built in Vector3/4/... outside of Burst
PS: soon™ https://docs.microsoft.com/en-us/dotnet/api/system.math.sincos?view=net-6.0
The text was updated successfully, but these errors were encountered: