Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

native C++ vs burst (what to expect?)

Discussion in 'Data Oriented Technology Stack' started by Mr-Mechanical, Dec 16, 2018.

  1. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    190
    I'm a big fan of the direction Unity is going with ECS. I'm just curious how fast burst would be compared to reasonably optimized native C++ code. Thanks.
     
  2. davenirline

    davenirline

    Joined:
    Jul 7, 2010
    Posts:
    441
    You can make this test easily. You can have an update that generates a random value then calculates the square root of that random value (or more square roots). Make 100k entities of this and call it in update. It's not that hard to replicate the same behavior in C++.
     
    Mr-Mechanical likes this.
  3. rizu

    rizu

    Joined:
    Oct 8, 2013
    Posts:
    990
    Well, the original question was kinda vague. If you do optimized native c++ code (with manually crafted SIMD optimizations) and task scheduler that makes it run in worker threads, it's likely to be tad faster than what we get with Burst. And if you just do naive c++ implementation without any multithreading at all, it's going to be way slower in comparison but that shouldn't surprise anyone.

    Afaik, the point isn't really that you'd beat manually crafted highly optimized native code in all cases but that you get similar gains with very little work on your end. Doing these things manually is really time consuming and after you've done it, you are less likely to be doing refactoring on that part of the code as it would be just really slow and painful to redo it all. With Unity's new approach, it's aiming to take a lot of that pain away and letting you write performant code out of the box.
     
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,183
    Not a possibility but a plan! As far as I know Unity plan to roll out ECS versions of everything so we'd probably not be able to get anywhere near the sum of performance Unity can do if we coded the entire thing in C++. We'd run out of staff and ship nothing just trying to keep up all the time.

    I don't doubt that larger developers have, over the years built up really strong performing code bases but they can't keep it up without non-trivial expense. All things being equal, it's dumb not to use Unity now even as mid-sized devs.
     
    Mr-Mechanical likes this.
  5. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,183
    Yep, and I've already shown one mid-sized AA company the light (you know who you are on these forums :p) and more will follow. It's actually ECS/Jobs/Burst that's convincing all these people to take a closer look at Unity. They're doing the math - can we keep up with our own tech? and more importantly... WHY are we doing this to ourselves when Unity has basically - the same perf with 20% of the code cost?

    A year ago I'd have shaken my head and made dismissive raspberry sounds. Now I'm shaking my head at people who aren't using Unity.

    Funny what a bit of time and space does.
     
    AlanMattano, RaL and Mr-Mechanical like this.
  6. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    164
    The goal for the first stable version of burst that will come later this year is to provide _at least_ the same performance than C++ code.
     
    FROS7 and Mr-Mechanical like this.
  7. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    458
    @xoofx Sounds interesting. I would like to see a performance comparison with a side-by-side code of a two benchmark programs that performs the same job under the hood, one compiled with MSVC/GCC/Clang, and another compiled with Burst. Maybe something like n-body, binary-trees, and basic stuff like recursive Fibonacci.
     
    Mr-Mechanical likes this.
  8. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    522
    Mr-Mechanical likes this.
  9. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    190
    This is seriously awesome. What are you guys thinking about GPU support with burst?