Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Resolved Should I always use Burst for more complex systems?

Discussion in 'Scripting Dev Blitz Day 2023 - Q&A' started by DevDunk, Feb 22, 2023.

  1. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,456
    I have asked a similar question in the past, without getting a concrete answer.

    Should I use Burst whenever I can?


    Many times I have a complex system, which on it's own isn't a performance concern, but when I have 20 of these systems might be. Think of these as single-threaded, so without the jobs system and without ECS (I know jobs have a scheduling overhead)


    Would it be recommended to generate Burst code where ever this is possible?
    So put all crucial calculations in a static class/method and compile this with burst?



    I currently don't have time to test this on a per-case basis, so only will change it when this becomes a performance concern, but always interested in info about this.
     
  2. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    412
    Hello DevDunk,

    It's difficult to come up with a definitive answer for this question. But, one advice that I have always used is to really use Burst for code path that you have profiled and identified as bottlenecks and for code path that you know can be easily translated to a Data Oriented Approach (e.g using structs, lots of data to process, no managed objects required, linear/sequential layout, good locality of the data, input and outputs clearly defined...etc.)

    Making sure that your code is Data Oriented friendly will be good regardless of using Burst or not. Specially, in the future, when we will switch to CoreCLR, as CoreCLR can bring excellent performance boost (while you can use managed objects), the investment that you will have done on your code/data layout will payoff as well with CoreCLR.