Posts Tagged performance

Burst-Compiled Generic Algorithms

Tags: , , ,

Many algorithms get used over and over: searching, sorting, filtering, etc. C# makes these available with LINQ and functions like Array.Sort, but these can’t be compiled by Burst because interfaces and delegates aren’t supported. So how do we implement these generic algorithms to avoid re-writing them over and over? Today we’ll explore one technique to solve this problem. Read on to learn how!

Read the rest of this article »

5 Comments

Steal Some More Bits

Tags: , , ,

Today we continue stealing float bits, but in an entirely different way this time. We’ll end up with the ability to switch between float and 21-bit integer modes and to know which mode we’re in. We can do all of this without using any more than four bytes just by exploiting a little knowledge of the float data format. Read on to learn how!

Read the rest of this article »

No Comments

Steal Some Bits

Tags: , ,

With a bit of understanding and some C# trickery, we can exploit how float works to cram in a few more bits and make some big performance gains. Today we’ll see how to steal some of the bits from a float!

Read the rest of this article »

No Comments

Math.Abs vs. Mathf.Abs vs. math.abs vs. Custom

Tags: , ,

A reader recently asked what the fastest way to take an absolute value was. It occurred to me that there are a lot of ways to do this in Unity! So today we’ll try them all out and see which is best.

Read the rest of this article »

7 Comments

NativeHashSet<T>

Tags: , , ,

Unity’s Native Collections package, currently in Preview, provides a hash map but not a hash set. Today we’ll supplement NativeHashMap<TKey, TValue> with our own NativeHashSet<T> as part of the NativeCollections repo. Read on for performance results and to see how to use it!

Read the rest of this article »

3 Comments

Assertions in Burst

Tags: , , ,

Assertions are an incredibly handy tool, but do they work in Burst-compiled jobs? Today we’ll find out!

Read the rest of this article »

6 Comments

How IL2CPP Calls Burst

Tags: , ,

Ever wonder how code compiled with IL2CPP can call code compiled by Burst? Today we’ll dive into the details and find out!

Read the rest of this article »

3 Comments

Burst’s FloatPrecision and FloatMode: Don’t Assume

Tags: , ,

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.

Read the rest of this article »

7 Comments

Use the Right Type for the CPU

Tags: , , ,

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.

Read the rest of this article »

5 Comments

Free Performance with Unity.Mathematics

Tags: , , , , ,

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.

Read the rest of this article »

5 Comments