Unity and a data-oriented approach

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?”
 
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
 
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.
 
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.
 
Last edited:
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?
 
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?
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.
 
They prevent race conditions by forcing you to write code with no race conditions. It's not a language feature:

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.

Data-oriented Unity

Burst compiler

The new job and entity component system
Unity CTO on the evolution of Unity to an entity component system.

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.

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.
it's cool how in his command line image to TGA program he monitors performance and resource usage with stopwatch.
 
Back
Top