Unity and a data-oriented approach

Discussion in 'Rendering Technology and APIs' started by Scott_Arm, Mar 12, 2018.

  1. Scott_Arm

    Legend

    Joined:
    Jun 16, 2004
    Messages:
    12,808
    Likes Received:
    2,853
    Cyan and BRiT like this.
  2. BRiT

    BRiT (╯°□°)╯
    Moderator Legend Alpha Subscriber

    Joined:
    Feb 7, 2002
    Messages:
    10,540
    Likes Received:
    5,928
    Location:
    Cleveland
    I'll take all their claims with an equal helping of salt...

    ~~~
    “A lot of people in the game industry have made a lot of multi-threaded games by now. There are a certain set of rules, we know how to write that code. But not everyone knows how to write it and that’s the problem. The very experienced people know there is a good way and there’s a way that always blows your foot off. And we’re just encoding those in a way that helps everyone do it in a way that works.”

    The new C# Job System makes it very clear what an instruction is reading from or writing to.

    At the end of the day, we can guarantee there are no race conditions in the code,” Ante says. Which is done through a combination of code analysis and runtime checks. “There is no game engine that has ever done that,” he adds. “So even someone who has never written multi-threaded before, you can trust that guy to write multi-threaded code.” And if he makes a mistake he gets an error message when he runs it, “and these messages are written with the principle of what would I tell a junior programmer if he made this mistake?”
     
    Cyan, milk and Silent_Buddha like this.
  3. Silent_Buddha

    Legend

    Joined:
    Mar 13, 2007
    Messages:
    15,174
    Likes Received:
    4,058
    Never say never...

    Especially when it comes to either inquisitive programmers (who want to try to break something) or inept programmers (who accidentally break things).

    Regards,
    SB
     
  4. psurge

    Regular

    Joined:
    Feb 6, 2002
    Messages:
    938
    Likes Received:
    35
    Location:
    LA, California
    There are languages that make data-races impossible by design. See for example Rust (when the unsafe escape-hatch isn't used, IIRC) or Pony.

    I didn't think C# was one of those languages (caveat: I don't program in C#), but the article also talks about invoking the "Burst" compiler to generate optimized code. That means new runtime checks could be inserted, and/or that jobs could be restricted to a subset of C# that is easier to make safe.
     
    Cyan, Scott_Arm and milk like this.
  5. Scott_Arm

    Legend

    Joined:
    Jun 16, 2004
    Messages:
    12,808
    Likes Received:
    2,853
    I've been learning Rust.
     
  6. OCASM

    Regular Newcomer

    Joined:
    Nov 12, 2016
    Messages:
    425
    Likes Received:
    314
    They prevent race conditions by forcing you to write code with no race conditions. It's not a language feature:

     
    Malo and BRiT like this.
  7. Scott_Arm

    Legend

    Joined:
    Jun 16, 2004
    Messages:
    12,808
    Likes Received:
    2,853
  8. OCASM

    Regular Newcomer

    Joined:
    Nov 12, 2016
    Messages:
    425
    Likes Received:
    314
    Today the Unity Central stream is going to be all about the ECS system.
     
    Scott_Arm likes this.
  9. OCASM

    Regular Newcomer

    Joined:
    Nov 12, 2016
    Messages:
    425
    Likes Received:
    314
    The talk that started it all (skip to the Q&A part for the butthurt :lol: ):

     
    jlippo and Scott_Arm like this.
  10. Scott_Arm

    Legend

    Joined:
    Jun 16, 2004
    Messages:
    12,808
    Likes Received:
    2,853
    Yah, this is a pretty great video. I've watched it a few times before.

    Watched this one a couple of days ago. Also good.

     
    jlippo, pharma and OCASM like this.
  11. OCASM

    Regular Newcomer

    Joined:
    Nov 12, 2016
    Messages:
    425
    Likes Received:
    314
    Scott_Arm likes this.
  12. Scott_Arm

    Legend

    Joined:
    Jun 16, 2004
    Messages:
    12,808
    Likes Received:
    2,853
    Data-oriented Unity


    Burst compiler


    The new job and entity component system
     
    Cyan and OCASM like this.
  13. Scott_Arm

    Legend

    Joined:
    Jun 16, 2004
    Messages:
    12,808
    Likes Received:
    2,853
    Looks like the Burst Compiler is pretty damned good already.

    http://aras-p.info/blog/2018/03/28/Daily-Pathtracer-Part-3-CSharp-Unity-Burst/

    Guy wrote a path tracer in C++ and tested it on PC and Mac, then ported it to C# and tested on PC and Mac. Lastly, he wrote it in Unity and tested it with the Burst compiler.

    C++ version runs at 136 Mray/s on PC, and 37.8 Mray/s on Mac
    C# (direct port) PC: 67.1 Mray/s, Mac: 17.5 Mray/s.
    Unity with IL2CPP instead of Mono: PC 28.1, Mac 17.1 Mray/s.
    Unity with Burst Compiler PC: 140 Mray/s (12x faster), Mac: 42.6 Mray/s (9x faster).
    Unity with Burst and their new experimental math library 164 Mray/s on PC, and 48.1 Mray/s on Mac

    In this case PC is threadripper and Mac is a macbook of some kind.
     
    #13 Scott_Arm, Mar 31, 2018
    Last edited: Mar 31, 2018
    Cyan, Lightman, CSI PC and 4 others like this.
  14. Scott_Arm

    Legend

    Joined:
    Jun 16, 2004
    Messages:
    12,808
    Likes Received:
    2,853
    Unity CTO on the evolution of Unity to an entity component system.

     
    Cyan and OCASM like this.
  15. Scott_Arm

    Legend

    Joined:
    Jun 16, 2004
    Messages:
    12,808
    Likes Received:
    2,853
    So with pro license you'll have full engine source that you can modify, like Unreal Engine. I guess that was not the case before?
     
  16. OCASM

    Regular Newcomer

    Joined:
    Nov 12, 2016
    Messages:
    425
    Likes Received:
    314
    Source code for the C# part of the engine. For the C++ part you still need the full license.

    Up until recently they didn't even had the C# part available for viewing.
     
    Cyan, Arwin and BRiT like this.
  17. Cyan

    Cyan orange
    Legend Veteran

    Joined:
    Apr 24, 2007
    Messages:
    7,802
    Likes Received:
    1,657
    data races are possible on C#, https://en.wikipedia.org/wiki/Race_condition

    I think @psurge had mentioned that he thought race conditions were impossible on C#, but was surprised by the fact they are possible.

    interesting, thanks, I've been several days without an internet connection because of the weather and the storms -it's been like 2 month raining here every day-, but will watch those videos when they get it fixed.

    it's cool how in his command line image to TGA program he monitors performance and resource usage with stopwatch.
     
    OCASM likes this.
  18. Scott_Arm

    Legend

    Joined:
    Jun 16, 2004
    Messages:
    12,808
    Likes Received:
    2,853
    BRiT likes this.

Share This Page

  • About Us

    Beyond3D has been around for over a decade and prides itself on being the best place on the web for in-depth, technically-driven discussion and analysis of 3D graphics hardware. If you love pixels and transistors, you've come to the right place!

    Beyond3D is proudly published by GPU Tools Ltd.
Loading...