Difference between IJobEntity, IJobChunk?

in EntityComponentSystemSamples\ECSSamples\BoidSystem.cs

I found that code partial struct InitialPerBoidJob : IJobEntity
automatically generates to the code partial struct InitialPerBoidJob : IJobChunk

and the file BoidSystem.cs automatically generates to the file BoidSystem__JobEntity_3566451.g.cs

so is IJobEntity equal to IJobChunk, if not, what difference between IJobEntity, IJobChunk?

Taken from the intro to entities documentation;

For jobs that access the entities matching a query, we have two special job interfaces:

  • IJobChunk, whose Execute() method processes an individual chunk matching the query.
  • IJobEntity, whose Execute() method processes the components of an individual entity matching the query.

IJobEntity is the convenience option, and IJobChunk is the fallback option for niche cases. In most cases, their performance is identical.

See examples of IJobChunk and IJobEntity.

To split the work of an IJobChunk or IJobEntity across multiple threads, schedule the job by calling ScheduleParallel() instead of Schedule(). When you use ScheduleParallel(), the chunks matching the query will be split into separate batches, and these batches will be farmed out to the worker threads. See related: EntityCommandBuffer.ParallelWriter

2 Likes

Thank you for your answer, this document has answered my question, but I have another question, that is: why the same partial structure can have different base classes…

Oh, that’s it, that’s the interface, I thought it was the class, thank you so much!