Posts Tagged performance

Free Performance with Burst

Tags: , , ,

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!

Read the rest of this article »

14 Comments

What are Your Latency Requirements?

Tags: , ,

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.

Read the rest of this article »

2 Comments

Fast Structs

Tags: , ,

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!

Read the rest of this article »

8 Comments

Object Graph Visualizer

Tags: , , , , ,

C# makes it easy to create large graphs of objects connected by their fields. The larger this graph grows, the more complex it is to deal with objects in the graph. It’s hard to look at code or set a breakpoint in a debugger and get an intuitive sense of all these connections. So today we’ll write a small tool to visualize an object graph!

Read the rest of this article »

5 Comments

IL2CPP Output for C# 7.3: Everything Else

Tags: , , , , ,

Today we conclude the series by looking at all the remaining features in C# 7.3 that we get access to in Unity 2018.3. Read on to learn about new kinds of structs, in parameters, new where constraints, discards, default literals, generalized async returns, and new preprocessor symbols!

Read the rest of this article »

3 Comments

IL2CPP Output for C# 7.3: Local functions, fixed, and stackalloc

Tags: , , , ,

Continuing the series, today we’ll dive into local functions, fixed-size buffers, fixed blocks on arbitrary types with GetPinnableReference, and stackalloc initializers to see how they’re all implemented in C++ and what assembly code ends up actually running on the CPU.

Read the rest of this article »

2 Comments

IL2CPP Output for C# 7.3: ref Return Values and Local Variables

Tags: , , , ,

Today we continue the series by looking at a pair of powerful, related features in C# 7.3: ref return values and local variables. These enable some great optimizations, so let’s look at the IL2CPP output for them to make sure it’s as good as it looks.

Read the rest of this article »

No Comments

IL2CPP Output for C# 7.3: Pattern Matching

Tags: , , , ,

Last week we started exploring the new features of C# 7.3 in Unity 2018.3 by delving into tuples. This week we’ll continue and look at pattern matching. Read on to see how the many forms of pattern matching are actually implemented by IL2CPP!

Read the rest of this article »

3 Comments

IL2CPP Output for C# 7.3: Tuples

Tags: , , , , , , ,

Unity 2018.3 officially launched last Thursday and with it comes support for the very latest version of C#: 7.3. This includes four new versions—7.0, 7.1, 7.2, and 7.3—so it’s a big upgrade from the C# 6 that we’ve had since 2018.1. Today we’ll begin an article series to learn what happens when we use some of the new features with IL2CPP. We’ll look at the C++ it outputs and even what the C++ compiles to so we know what the CPU will end up executing. Specifically, we’ll focus on the new tuples feature and talk about creating, naming, deconstructing, and comparing them.

Read the rest of this article »

3 Comments

Supporting ParallelFor Jobs in Ranged Native Collections

Tags: , ,

Native collections are funny things. On one hand they’re structs, which are supposed to be value types that get copied on assignment. On the other hand, they act like reference types because they contain a hidden pointer internally. This can make using and implementing them difficult to understand, especially in the context of a ParallelFor job. Today we’ll examine more closely how to properly support ParallelFor jobs, especially with ranged containers like NativeList<T>.

Read the rest of this article »

No Comments