Archive for category Unity

LINQ-Style Generic Algorithms for Burst

Tags: , , ,

We’ve seen how to create powerful, Burst-compatible generic algorithms already, but today we’ll take another approach to generic algorithms and implement them in the style of C#’s LINQ. Along the way, we’ll tackle a new challenge by implementing a generic algorithm that allocates a new collection.

Read the rest of this article »

2 Comments

Thread Synchronization Performance

Tags: , , , ,

Multi-threading is essential to performance on all modern processors. Using multiple threads brings along with it the challenge of synchronizing data access across those threads. Unity’s job system can do some of this for us, but it certainly doesn’t handle every case. For times when it doesn’t, C# provides us with a bunch of synchronization options. Which are fastest? Today we’ll find out!

Read the rest of this article »

4 Comments

Type-Agnostic Generic Algorithms

Tags: , , ,

We looked at some generic algorithm examples in the previous article, but they weren’t very generic in one respect: they all required a NativeArray<T>. What if we wanted to make them more generic so they could work on any type of collection? Today’s article shows two ways to do just that!

Read the rest of this article »

2 Comments

Generic Algorithm Examples

Tags: , ,

There are many common algorithms that we use constantly: searching, filtering, mapping, and so forth. Today we’ll write a few in the Burst-friendly way as examples of how to write Burst-friendly code that’s still reusable and efficient.

Read the rest of this article »

4 Comments

How SharedStatic Works

Tags: , , , ,

Burst 1.2 comes with a new feature: SharedStatic<T>. This allows us to write to static variables from within Burst-compiled code like jobs and function pointers. Today we’ll look at how this is implemented by Burst and IL2CPP. We’ll also put them to a performance test to see how fast they are.

Read the rest of this article »

4 Comments

Function Types: A Spectrum

Tags: , , , ,

C# gives us lots of types of functions for us to call. We must constantly decide between them. Should this function be static? Should it be virtual? There are many factors that go into making the decision. Today we’ll look at the function types as a spectrum and hopefully get a little perspective on our options.

Read the rest of this article »

5 Comments

Burst Function Pointers vs. Jobs

Tags: , , ,

Function pointers aren’t the only way to express a unit of work. Unity’s own job system does just this, albeit in a different way. Today we’ll compare the performance of Burst’s function pointers against jobs themselves!

Read the rest of this article »

3 Comments

Burst Function Pointers vs. Switch Statements

Tags: , , ,

A couple weeks ago we took a look at the performance of function pointers in Burst. In doing so, we left out an alternative: good old switch statements. Today we’ll put those to the test to see how they stack up next to Burst’s newfangled function pointers!

Read the rest of this article »

4 Comments

DIY Virtual Functions in Burst

Tags: , , , , ,

Now that we’ve seen how function pointers work and perform in Burst, let’s use them to build a higher-level feature: virtual functions!

Read the rest of this article »

3 Comments

Burst Function Pointers Performance

Tags: , , ,

Last week we took a look at function pointers in Burst 1.2 and Unity 2019.3. Today we’ll continue looking into them by analyzing their performance.

Read the rest of this article »

4 Comments