Search Unity

Researching traditional Multithreading, people suggest more than 2 cores is not worth it.

Discussion in 'Entity Component System' started by Shablo5, Dec 31, 2019.

  1. Shablo5

    Shablo5

    Joined:
    Mar 2, 2015
    Posts:
    40
    In my research of DOTS, i've spent some time researching Multithreading as a whole. This has brought me to two perceived problems (posed by the sites visited):

    "Multithreading works well at 2 cores, and falls off the more you add"

    "Multithreading above 2 cores is ridiculously dev-time heavy. Above 2, you'll spend too much time writing safe code, and way more time debugging it"

    Are either of these statements accurate, and if so, how does the DOTS get around these issues? I read in a DOTS breakdown here that Unity determines how many cores to use on a platform by platform basis, and can sometimes overestimate how many cores are even available, hurting your performance.

    It feels like i'm starting to get into the weeds here, but I just want to better understand DOTS and Multithreading better.

    Anyone out there understand all this?
     
  2. justin_sunblink

    justin_sunblink

    Joined:
    Dec 3, 2019
    Posts:
    18
    Most assumptions about multithreading assume that you will be manually managing thread pools and/or dealing with explicit locking primitives. There are very often problems around deadlocks, determinism, data race conditions, and cache thrashing. I have done a lot of such programming outside of the context of games, and not once have I ever considered it for game logic because of these reasons and more.

    DOTS has none of the problems. The multithreading system is inherently free of all those issues by-design. Writing systems that operate on collections of components also forces you to write game logic that is inherently parallelizable across as many cores as you can throw at it. I've worked in DOTS for a year now full-time and I can confidently say it delivers on every promise in this regard.