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. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Trigger event and Collision event performance

Discussion in 'DOTS Physics' started by WAYN_Games, Apr 3, 2020.

  1. WAYN_Games

    WAYN_Games

    Joined:
    Mar 16, 2019
    Posts:
    869
    Hello,

    From what I can tell, tigger event and collision event are consumed in a single threaded job and to access data related to the entities we have to use the GetComponentDataFromEntity.

    My question is in regard of performance for that pattern.
    The event themselves are (obviously) layed out nicely in memory so there is no issue iterating over it.
    My main concern is with the GetComponentDataFromEntity. When fetching data for one of the entity of the event, how is that fetch optimized ?

    If we have many entities with that particular compoennt, I assume we may get ot a point where we are not able to fit everything in the cpu cache memory.

    So in this configuration, is the cpu able to prefetch the data ? knwoing that we will iterate over the next entites referenced by the event, it should be possible to prefetech the necessary compoennt data.
     
  2. WAYN_Games

    WAYN_Games

    Joined:
    Mar 16, 2019
    Posts:
    869
    Based on this wikipedia article https://en.wikipedia.org/wiki/Cache_prefetching it seem that my assumption is almost correct.
    It seem that the hadware prefetching done by the CPU is only for linearly layed out memory elements.
    While the software prefetching is done through code analysis by the compiler.
    I'll have to take a look at the burst compiler to see if it has such capabilities.

    If someone already knows please feel free to post it here for others and possibly to avoid me seaarching :), cheers.
     
unityunity