What's the benefit of Burst compiling ISystem struct?

In our codebase we have ISystem structs where we add the [BurstCompile] attribute to OnCreate/OnUpdate/OnDestroy callbacks where possible.

I always assumed that if I added [BurstCompile] to the system struct that meant that all methods inside would also be Burst compiled, but based on some quick testing that does not appear to be the case.

This begs the question, what is the benefit of also adding the [BurstCompile] attribute to the system itself? And if I have some system callbacks that are not Burstable, does this cause an issue?

Read the above post.

The gist for ISystem is that to have Burst-compiled callbacks OnCreate/OnUpdate/etc., you just need to add BurstCompile on the method.

For any normal Burst entry points (static methods, as instance methods aren’t supported without special things like job Execute methods and ISystem callbacks that do ultimately use static methods to wrap your instance methods), you need the attribute on both the method and the containing type. BurstCompile needs to be on the ISystem for normal Burst methods, just like any other type. The difference is that BurstCompile is added automatically behind the scenes when the system source generator creates code to support SystemAPI and entity job usages. If the system generator doesn’t produce output for the system (from the system not needing source generation), BurstCompile needs to be manually added to the type.

1 Like