Just How Much Garbage Does LINQ Create?

Tags: , , ,

LINQ’s CPU performance is quite poor, but how is it with memory? Does every LINQ function always create tons of garbage for the GC to collect, or are there exceptions that aren’t so bad? Today’s article tests out lots of LINQ functions to find out!

Read the rest of this article »

1 Comment

How FixedUpdate Works

Many Unity programmers misunderstand FixedUpdate because it seems so basic. Usually it behaves in the simplistic way it’s thought to work, but there are important exceptions that are often forgotten. Today we’ll take a closer look at FixedUpdate to get a better handle on how it works and learn to use it correctly.

Read the rest of this article »

1 Comment

LINQ Performance Update

Tags: , ,

It’s been over three years since the last article on LINQ performance. That was all the way back in the Unity 5.0 days using Mono as a scripting backend. Today we’ll update that article’s test with Unity 2018.1 and IL2CPP to see how LINQ fares these days. Is it any better? Read on to find out!

Read the rest of this article »

1 Comment

Exotic CPU Instructions

Tags: , ,

Programming in high-level languages like C# often presents the illusion that the CPU is only capable of a few primitive operations like “add,” “multiply,” “push,” “pop,” and “move.” After all, those are the primitive operations that we write all of our C# code with. The reality is quite different. Modern CPUs have hundreds of instructions for tons of special-purpose operations. Entire algorithms in C# are built right into the CPU and can be executed with one instruction. Today we’ll look at some of these exotic instructions as a reminder of what CPUs can really do and see how we can tap into this potential.

Read the rest of this article »

4 Comments

Job System Tutorial

Tags: , ,

The new Job System debuted recently in Unity 2018.1 and began the process of changing how virtually all Unity scripts will be written. In conjunction with the forthcoming ECS and Burst compiler, the old MonoBehaviour-based programming paradigm will eventually be replaced. Today’s article is a tutorial for how to get started learning the new way of writing Unity scripts.

Read the rest of this article »

No Comments

C++ Scripting: Part 31 – Init Improvements

Tags: , ,

The C++ Scripting series continues today by going over some internal improvements that don’t add any features, but make the existing system more robust. We’ve lucked out in a couple of areas and today we’ll take the opportunity to fix them and learn about some inner workings of C++ and C# along the way.

Read the rest of this article »

2 Comments

IL2CPP Output for Iterators, Switch, and Using

Tags: , , ,

Today we’ll look at the C++ code that IL2CPP outputs when we use iterator functions (those that yield), switch statements, and using blocks. What are you really telling the computer to do when you use these C# features? Read on to find out.

(Website Announcement: check out the new tags page to find articles by topic)

Read the rest of this article »

No Comments

How to Make Custom Native Collections

Tags: , ,

We’ve seen how NativeArray works, but what if we want more kinds of native collections? Unity 2018.1 only has that one, but you can make your own! Today’s article shows exactly how to do that.

Read the rest of this article »

No Comments

C# Type Tricks

Tags: , , , ,

A lot of powerful language features like LINQ require massive performance hits, but today we’ll discuss some easy, low-overhead ways to add some safety and usability to C#.

Read the rest of this article »

No Comments

How NativeArray Works

Tags: ,

NativeArray<T> is a new type introduced recently in Unity 2018.1. It’s like List<T> except it’s backed by an unmanaged array instead of a managed array. It’s also a struct instead of a class. This means it creates no garbage for the GC to later collect. That’s the surface level description, but today we’ll go in depth to find out how it really works and learn some interesting facts along the way.

Read the rest of this article »

No Comments