Hi,
I have working in editor bursted static functions that are being called from regular C#, and the speedup, as usual, is massive. But profiling the build on Android, the bursted method versions don’t seem to be running. There is no speedup compared to a build without burst and the profiler isn’t listing the method names with the ‘Burst’ part. Any ideas why this wouldn’t work?
Many thanks
Hello @OffgridChris - please could you check your Burst AOT Player Settings, to ensure that “Enable Burst Compilation” is checked for Android? If possible please post a screenshot of that window in your project settings here.
There is no speedup compared to a build without burst and the profiler isn’t listing the method names with the ‘Burst’ part.
Depending on exactly what your static methods are doing, it is plausible that Burst wouldn’t give much of a speedup compared to IL2CPP. I know the profiler has Burst appended for jobs, but I’m not sure it does that for static methods - please could you check in the Editor profiler to see if the Burst-compiled methods have Burst appended?
One way to confirm whether Burst is enabled or disabled is to do this, and call BurstHelper.CheckIfBurstEnabled()
from a MonoBehavior:
[BurstCompile]
private static class BurstHelper
{
[BurstDiscard]
private static void SetIfManaged(ref bool b) => b = false;
[BurstCompile]
private static void CheckIfBurstEnabled()
{
var b = true;
SetIfManaged(ref b);
Debug.Log($"Burst is enabled: {b}");
}
}
Thanks for the reply! “Enable Burst Compilation” is already ticked for Android, unfortunately, so I don’t think that is it.
In the editor, ‘Burst’ is appended to the function names but on our device build they are not, which is another reason why it feels like burst just isn’t running for some reason. We will try the BurstHelper as that should give us a definitive answer. Will report back…
Adding onto the enable part mentioned above by Mr Jones, check also that a reimport / IL2CPP cache flush has occurred before you build. Might even be worthwhile reimporting all just to make sure there isn’t some stale cached settings somewhere.
Thanks for the tip! I’ll give that a try
The call to CheckifBurstEnabled() does return true on Android but I’m still very suspicious I’ve used Burst extensively with DOTS and know how incredibly fast it is. This is the first time I’ve used it in this way - calling bursted static functions from regular C# - but I expected a similar speedup and in fact I see a 60x speedup in editor. I’m just baffled why I’m not seeing even the slightest speedup on device. Absolutely nothing! I get your point @tim_jones about IL2CPP. This just hasn’t been my experience so far.
To confirm that the specific method you actually care about is being Burst-compiled, you could call CheckIfBurstEnabled
as a normal method call from inside your “real” Burst-compiled method:
[BurstDiscard]
private static void SetIfManaged(ref bool b) => b = false;
private static void CheckIfBurstEnabled()
{
var b = true;
SetIfManaged(ref b);
Debug.Log($"Burst is enabled: {b}");
}
// elsewhere, in your "real" Burst-compiled code:
CheckIfBurstEnabled();