Search Unity

Does ISharedComponentData setup influence IJobParallelFor batches?

Discussion in 'Entity Component System' started by Mr-Mechanical, Nov 22, 2018.

  1. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    I am looking for clarification

    SharedComponentData Docs:
    "Entities with the same SharedComponentData are grouped together in the same chunks. The index to the SharedComponentData is stored once per Chunk, not per Entity. As a result SharedComponentData have zero memory overhead on a per Entity basis."

    IJobParallelFor docs:
    "Unity automatically splits the work into chunks of no less than the provided batchSize, and schedules an appropriate number of jobs based on the number of worker threads, the length of the array and the batch size."

    Does this mean that SharedComponentData influences how batches are made with IJobParallelFor? I would assume not otherwise. But, I just want to make sure I understand, since I want optimal batch sizes for this use case.
     
    Last edited: Nov 22, 2018
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
    In Unity automatically splits the work into chunks they mean not archetype chunk but just part of data. in your case you must use IJobChunk for using ISharedComponent data as some sort of divider\filter for archetype chunks.
     
    Mr-Mechanical likes this.