Posts Tagged performance

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 »

2 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

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 »

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

Can Fixed-Point Improve Performance?

Tags: , , , ,

Fixed-point types save memory compared to floating-point types, but can they also improve performance? Today’s article finds out!

Read the rest of this article »

3 Comments

Sub-Byte Sizes: Part 2

Tags: , ,

Today we continue to explore how we can store values in less than a byte. We’ll expand the BitStream struct with the capability to write values in addition to just reading them. Read on to see how to implement this functionality and for the full source code which you can use in your projects.

Read the rest of this article »

No Comments

Sub-Byte Sizes: Part 1

Tags: , ,

The smallest a C# type can be is one byte. The byte type and and an empty struct are examples of this. But what if we want to store data in less than a byte to improve performance such as load times and CPU cache utilization? Today’s article does just this by packing at the bit level!

Read the rest of this article »

2 Comments

Fixed-Point: Shrink Data Sizes 4x

Tags: , , ,

Floating-point math is fast these days, but fixed-point still has a purpose: we can use it to store real numbers in less than 32 bits. Saving a measly 16 or 24 bits off a float might not sound appealing, but cutting the data size in half or quarter often does when multiplied across large amounts of real numbers. We can shrink downloads, improve load times, save memory, and fit more into the CPU’s data caches. So today we’ll look at storing numbers in fixed-point formats and see how easy it can be to shrink our data!

Read the rest of this article »

4 Comments

Adding Bit Fields to C#

Tags: ,

Bit fields give us the ability to use less than one byte to store an integer. This can be really useful to fit more data into a CPU cache or to reduce memory usage in general. Unfortunately, bit fields aren’t built into C#. Today we’ll work around that by creating our own!

Read the rest of this article »

6 Comments