Unity 2019.1’s new Burst job compiler has two options to increase performance even further: FloatPrecision
and FloatMode
. By sacrificing some exactness in our calculations, we should be able to increase speed. Today’s article is about using those options and examining the results to verify the results.
Archive for category Unity
The Unity.Mathematics package documentation has a curious statement: “Note that currently, for an optimal usage of this library, it is recommended to use SIMD 4 wide types (float4, int4, bool4…)” Today we’ll explore why we should consider using float4
, not float3
, after years of using Vector3
.
Along with Unity 2019.1 and Burst, the Unity.Mathematics package is now out of Preview. It offers alternatives to longstanding core types in Unity such as Vector3
, Matrix4x4
, and Quaternion
. Today we’ll see how switching to these types can improve performance in Burst-compiled jobs.
Unity 2019.1 was released last week and the Burst compiler is now out of Preview. It promises superior performance by generating more optimal code than with IL2CPP. Let’s try it out and see if the performance lives up to the hype!
We create objects out of structs and classes all the time, but oftentimes these evolve to the point where using them is really awkward. Today we’ll learn to recognize the telltale signs of an overextended object design and how to easily fix it.
In last week’s tips for using collections like List<T>
, we saw how struct types are sometimes boxed resulting in GC allocations. This week we’ll see how to avoid boxing and learn some of the clever tricks that .NET collection types use to make this possible.
Collection types like List<T>
and Dictionary<TKey, TValue>
are fundamental tools in C#. Sadly, I keep seeing the same misuses of them in codebase after codebase. Today we’ll look at the top 5 problems and learn how to easily avoid them!
Unity’s Mike Acton gave a talk this week at GDC titled Everyone watching this is fired. One point he made was regarding the importance of knowing the latency requirements of our code. When does the result need to be ready? Today we’ll talk about the ramifications of answering that question with anything other than “not immediately” and see how that can lead to better code.
Structs are great for controlling memory layout and avoiding the GC, but we can go a lot further to get even more speed out of them. Today we’ll look at a simple tweak that can dramatically speed up the code using the structs without even changing it!
C# already has two bit array types, but both are lacking. BitArray
is a class
so it requires heap allocation and GC. BitVector32
is a struct
, but it’s usage is bizzare, it’s implemented inefficiently, it’s not enumerable, and there’s no 64-bit version. Today we’ll create a new, simple type to remedy these issues and add a new tool to our toolbox!