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.
  2. Dismiss Notice

Is there a way to change the number of worker threads used by the Job System?

Discussion in 'C# Job System' started by OFFICIAL_bryanw, Aug 2, 2018.

  1. OFFICIAL_bryanw

    OFFICIAL_bryanw

    Joined:
    Jul 6, 2018
    Posts:
    36
    Is there a way to change the number of worker threads used by the Job System?

    I want to see if my performance would be better if it didn't use all of the threads...
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,579
    Don't know the answer, from the coding point of view. But if you on windows OS, in task manager you can try change in processes -> processor affinity, to desired cores. Not sure however, if this will work. But technically should.
     
  3. OFFICIAL_bryanw

    OFFICIAL_bryanw

    Joined:
    Jul 6, 2018
    Posts:
    36
    Thanks! I tried that out and it looks like you can change the number of cores it can use, but Unity will still try to make the same number of worker threads...

    Interestingly enough, I am trying to profile RaycastCommand jobs, and I somehow get better performance when I set the Affinity to only use 3 cores...
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,579
    how many raycast rays you project?
     
  5. samizzo

    samizzo

    Joined:
    Sep 7, 2011
    Posts:
    487
    Changing the processor affinity just changes which cores or how many cores the threads will run on. It doesn't affect the number of threads which is controlled by Unity and apparently not exposed.

    Sam
     
  6. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,579
    From what you saying, I think exposing could be good, to do deep testings, on multi threading.
     
    OFFICIAL_bryanw and samizzo like this.