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.

Bug Unity games only using 1 thread even when multithreading is active

Discussion in 'Editor & General Support' started by GradientOGames, Jul 15, 2022.

  1. GradientOGames

    GradientOGames

    Joined:
    Feb 8, 2021
    Posts:
    28
    I don't know why but when I turn on burst compiling and unity jobs and multithreading (and turn on consistency sorting) when I build and run, I spawn an insane amount of rigidbody2ds the cpu usage on taskmanager is 16.66% (exactly one thread). Is there anything I'm missing?
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    6,243
    Have you actually coded in systems to use Burst/Jobs, or are you thinking Unity magically does it for you?
     
    Last edited: Jul 15, 2022
  3. GradientOGames

    GradientOGames

    Joined:
    Feb 8, 2021
    Posts:
    28
    Wait... really? I was told otherwise. Well then how would I set it up?
     
  4. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    6,243
    Well you misunderstood whomever that was, or they were wrong. The king's ransom of Unity happens on a single thread. Burst/Jobs gives you access to an API for performing thread safe operations, though it's not something I've ever used as the requirement hasn't come up.
     
  5. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,397
    And before you dabble into it: most non-DOTS APIs such as Physics2D are not (fully) threadable. That is why we have DOTS Physics (in two versions, Unity and Havok but not 2D specific yet).

    If an API supports Native* containers such as MeshData it is (likely) threadable.
     
  6. GradientOGames

    GradientOGames

    Joined:
    Feb 8, 2021
    Posts:
    28
    So to do 2D stuff on dots, you just use 3d rb but with certain constraints, am I right?