taskforce

2023.05 - High-Performance Collections: Multithreading, Burst, Jobs! <3

May 1, 2023 ยท 3 min read

Most teams do not lose performance in one giant bug. They lose it through small managed overheads that keep showing up in hot loops: allocations, garbage collector pressure, and containers that are convenient but not built for the kind of CPU pressure games create.

This module is the reality check. Unity.Collections can help a lot, but not in the childish way of "replace every List with NativeList and call it a day". Some switches are faster, some are slower, and the answer changes again when you bring in Burst, safety checks, and unsafe variants.

Converting a mesh deformation example from arrays to NativeArray-based code.

Start here: look at one hot path that runs every frame and ask a boring but important question: is this container holding basic value types that could live in a native container instead of a managed one? If the answer is yes, that is your first candidate for NativeArray, NativeList, or one of the parallel-friendly maps and sets.

First warning: do not enable this blindly. Native containers give you more responsibility, not just more speed. The module shows the restrictions that come with them: value-type-only data, allocator choices like TempJob vs Persistent, explicit disposal, and the fact that parallel writes need the right container or writer path.

Unity Collections benchmark table comparing NativeList, unsafe variants, Burst, and safety checks.

The proof is here: the benchmark story is not one-dimensional. In the module, Ruben points out that adding 10,000 elements with a regular C# list is about 0.015 ms, while a NativeList with safety checks can be slower at about 0.148 ms. Then the picture flips when you use Burst and the right variant: UnsafeList with Burst lands around 0.005 ms, roughly 3x faster than the managed reference in that case.

CEO/Producer translation: this is how you stop bleeding CPU time through "small" habits that pile up across systems, features, and content.

The members-only module is the full step-by-step playbook: the container taxonomy, allocators, NativeArray-to-Job-System migration path, multi-thread writer gotchas, concrete examples like mesh extrusion and NativeParallelHashMap, plus the benchmark interpretation that tells you when the switch is worth it and when it is not.

Join the membership to unlock the full module, audio, and resources.

In this module:

Join to unlock the full module, audio, and resources.