Search Unity

Does IJobProcessComponentData run in parallel?

Discussion in 'Entity Component System' started by wusticality, Feb 24, 2019.

  1. wusticality

    wusticality

    Joined:
    Dec 15, 2016
    Posts:
    71
    Hey all, I had a quick question about
    IJobProcessComponentData
    . I've seen spurious documentation claiming that
    IJobProcessComponentData
    runs in parallel similar to
    IJobParallelFor
    . I'm trying to understand how
    IJobProcessComponentData
    determines the batch size. If it sets the batch size to
    1
    then wouldn't that be less efficient than using
    IJobParallel
    and setting the batch size to something like
    32
    ,
    64
    ,
    128
    , etc.?

    Thanks in advance!
     
  2. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    If I am not wrong it goes parallel per chunk
     
  3. wusticality

    wusticality

    Joined:
    Dec 15, 2016
    Posts:
    71
    So it processes 16k of data per core at a time I guess?
     
  4. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    Yes, if the chunk is full. I never really looked into the source or read a detailed explanation, my understanding is that it is just an abstraction layer of IJobChunk (i.e. the inner loop)
     
  5. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Not necessarily 16kb of data being processed. Most jobs don't access all components.

    For most of the data in MegaCity the 16kb chunk size is somewhere between 50 ... 128 entities per chunk.
     
    Antypodish likes this.
  6. wusticality

    wusticality

    Joined:
    Dec 15, 2016
    Posts:
    71
    Oh I see, so it's going to process some number of entities based on the archetype size but the amount of data depends on which components you're actually accessing. Thanks very much for the clarification!