Search Unity

EntityQuery adding +/- 1ms to system's performance overhead?

Discussion in 'Entity Component System' started by thelebaron, Oct 16, 2019.

  1. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    857
    Let me just say that I did resolve this particular issue but the nature of it still confuses me so just laying it out here for analysis.

    My PlayerControllerSystem was taking a little over 1ms of performance in editor(note I cant debug in a build for now as the player doesn't build correctly, so all measurements are from editor for the moment), its more or less based on the physicssample controller so I was rather annoyed at the performance hit for this one system that was only dealing with a single entity.

    After some digging, I found that it was due to using another entityquery to feed a component into the jobs, my PlayerMovement job required a PlayerInput component to function. Just doing PlayerInput = new PlayerInput(); dropped the ms to 0.03ms or something much more reasonable, as opposed to 1ms.

    Now I fixed it by realising PlayerInput existed on the same entity that the jobs work on, so just added it to the ForEach components but some time ago prior to refactoring etc I was maxed out on components for that job(and made it before I knew how to use chunk iteration) so I was getting it outside of the job.

    Is the performance hit that I was experiencing due to it being on the same chunk, and that would be the expected result of structuring it in a bit of a roundabout way? Or should this not have happened?
     
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683
    If your EQ relies on some entities which processed by other systems with RW before, it needs to wait till thes systems done, before start doing some thing. It's not "performance" of system, I'm sure if you check profiler it will be semaphore waiting, system performance itself should stay same.
     
    Kuptsevych-Yuriy and thelebaron like this.
  3. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    857
    thanks, I did notice the semaphore being the culprit in the profiler though I wasnt sure why it was waiting, but this clears that up