Unity burst optimization
Writes highly optimized, multithreaded unmanaged C# jobs. Use when compiling mathematics, physics, or ECS loops through the LLVM Burst Compiler.From its SKILL.md
npx -y skills add meyverick/agy-skills --skill unity-burst-optimizationAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
2.2 KB, 485 tokens by cl100k_base, as published. Nobody here has run it
Unity Burst Optimization
This skill enforces strict unmanaged memory rules required to successfully compile C# code through Unity's LLVM-backed Burst Compiler, preventing automatic fallbacks to slow managed execution.
When to Use
- Use when writing
IJob,IJobParallelFor, orISystemupdate loops. - Use when allocating native memory via
NativeArrayorNativeHashMap. - NOT for garbage-collected standard C# scripts.
Core Process
Phase 1: Unmanaged Constraints
- Burst cannot compile anything that touches the Garbage Collector.
- You must exclusively use blittable types (primitives, and structs composed only of primitives).
- Banned types:
class,string,char[],object,delegate.
Phase 2: Native Allocations
- Use
Unity.Collections(e.g.,NativeArray<T>) for collections. - You MUST pair every
Allocator.TemporAllocator.Persistentwith an explicit.Dispose()call. Failure to do so results in a memory leak.
Phase 3: Mathematics
- Use
Unity.Mathematics(e.g.,float3,quaternion) instead ofUnityEngine.MathforVector3, as it is explicitly mapped to SIMD hardware instructions by Burst.
Common Rationalizations
| Rationalization | Reality |
|---|---|
| "I'll just pass this C# string into the job to print it." | Strings are managed classes. Burst will either fail to compile or throw a safety error. Use FixedString32Bytes. |
"I don't need [BurstCompile], the multithreading alone is fast enough." | Burst compilation often yields a 10x-50x speedup over standard C# multithreading due to LLVM SIMD vectorization. |
Red Flags
- Utilizing
UnityEngine.Vector3inside a Burst job instead offloat3. - Allocating a
NativeArraywithout a correspondingDispose()or dependency management.
Verification
Before finalizing the Burst job, verify:
- The
[BurstCompile]attribute is present on the struct/system. - Zero managed types (classes, strings) are referenced inside the job.
- All native collections are explicitly disposed to prevent memory leaks.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.