Search Unity

Iterative processing with Job System.

Discussion in 'Data Oriented Technology Stack' started by Kichang-Kim, Dec 19, 2018.

  1. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    311
    Hi, I made simple Position Based Dynamics system with ECS and Job system. It quite works well but I have some concern about its implementation.

    My concern is about iterative job sets. Here is PBD algorithm which I used:

    1. Predirct next position by verlet integration (IJobParallelFor) : Job count = 1
    start loop until solver iteration count
    2. Solve Constraints for each constraint types (Per type IJobParallelFor) : Job count = Constraint Type count + other jobs (averaging solve deltas, clear temporary containers, and so on)
    end loop
    3. Assign final next positions to current positions

    The problem is that many jobs are created when I increased solver iteration count. When solver iteration count is small (1~30), its okay. But how about 1000~? single system schedule massive jobs every frame, then CPU load of scheduling job may be bigger than actual work processing load.

    Is there any solution about this situation?

    Thanks.
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    4,671
    If the work per job is roughly > 0.1ms then it is no problem, in terms of perf (Overhead of schedule + job execution)

    Having more iterations creates more actual work. It is not required to have larger jobs just because there is more work in total. Its fine to just have more reasonably small sized jobs. (Just not too small)

    So the concern should actually be about what happens when you have too few entities for such a scheduling model. If thats not the case, there is no problem.
     
    Kichang-Kim likes this.
  3. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    266
    Speaking of... can we do something about it? I takes for my use case almost 3ms if TransformAccesArray is big (like 100k big). I managed to do almost completely async transform manipulation, this is only thing taking considerable time on main thread.
     
  4. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    4,671
    TransformAccessArray implies that you are using game objects. For performance at massive scale you want use pure entities with no game objects associated to them.