Search Unity

Trigger event and Collision event performance

Discussion in 'Physics for ECS' started by WAYNGames, Apr 3, 2020.

  1. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    992
    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. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    992
    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.
     
    Fenikkel likes this.