Search Unity

How can I be sure that burst runs?

Discussion in 'Burst' started by fholm, Feb 8, 2019.

  1. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    I have a job that I've had a lot of problems getting compiling in burst, i finally managed to get it compile (shows up in burst inspector, can look at the assembly/il/llvm ir, etc.).

    But... the job runs at the same speed (or slightly slower? not sure) as it did without burst, which seems really weird - how can I be sure that burst executes and it's not defaulting to the non-burst variant of the job?
     
  2. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    Here's the avarage execution times over 1000 runs:

    1) Burst = avg: 0.99ms, stddev: 0.02
    2) Non-Burst: avg: 0.95ms, stddev: 0.012

    So this seems like... the burst version of the job is either not running - or it's executing slower than non-burst, which seems really weird?
     
  3. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    In the profiler. Go to timeline view. There you should see (burst) at the end of the jobs if they are compiled with the burst compiler.
     
  4. RecursiveEclipse

    RecursiveEclipse

    Joined:
    Sep 6, 2018
    Posts:
    298
    Alternatively, when looking at the jobs/systems list in burst inspector, only jobs eligible for burst are black(not greyed out). You could also try restarting Unity & toggling burst off/on, or enabling burst safety checks to be sure something isn't failing, sometimes it doesn't compile for some reason even when turned on until you toggle it.
     
  5. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    So, I managed to get it running - and indeed it was not executing under burst before. Here are the new figures (this is in IL2CPP in build, the previous numbers were in editor - which is why they dont match):

    Burst: avg:0.14ms, stddev: 0.017
    Non-Burst: avg: 0.2ms, stddev: 0.21

    So burst is around 25% faster... and now it is 100% executing in burst, as the jobs both show up in the burst inspector and shows with a (Burst) tag in the profiler.
     
  6. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,769
    Also, depending on type of algorithms you are running, you can get gain from burst, anything from few % to many hundreds % improvement.
     
  7. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    Yes, this I'm aware of... i think the calculations im doing are not very easy to use AVX/SIMD instructions for
     
  8. Nothke

    Nothke

    Joined:
    Dec 2, 2012
    Posts:
    112
    Also make sure you are using the mathematics library. No one mentioned it but I assume you are using it. I regularly get 50x-200x speedups for 3d vector calculations, once I got 300x for large float3 arrays using the noise library which is truly insane.

    You can also check how much your code is simdified by scanning assembly in the burst inspector. If you see many lines that have multiple values per instruction (like: instruction value1 value2 value3 value4) those are using simd.
     
    Deleted User and Antypodish like this.
  9. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    So there's no maths being done at all, it's a delta compression job for my networking system.

    There's very little room for burst to do its magic as it's all generic pointer manipulation and reading things through byte offsets. Only way I can get burst to speed it up is to hardcode the delta checks for each component type.

    Edit:
    I have it down to 0.15ms to calculate deltas for 1100 entities where 1000 are simple ones and with just 2-3 small components 100 are heavier ones with tons of state.

    This is all on the main thread, using jobs but not with threading.
     
    Last edited: Feb 8, 2019