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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Why do we need [UpdateInGroup], [UpdateBefore], [UpdateAfte and input/output dependencies?

Discussion in 'Entity Component System' started by MNNoxMortem, Nov 22, 2020.

  1. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    Not important, but I am curious: Why do we need both? Shouldn't the input and output dependencies already define everything required - or if we define an attribute, shouldn't that essentially be equal to using the input/output dependencies?

    What if those two contradict, which one will actually win?
    What if attributes and/or dependencies contradict each other?
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,631
    [UpdateInGroup], [UpdateBefore], [UpdateAfter] only define the order the systems run, not the order jobs are scheduled executed unless you enable simple dependency mode.
     
    Last edited: Nov 22, 2020
    Egad_McDad and MNNoxMortem like this.
  3. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    D'oh. Yes. Obvious. Thanks anyway.
     
  4. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,631
    I made a graphic for this a while ago for the importance of read/write but it also includes difference with simple dependency

    upload_2020-11-23_7-14-50.png

    People tend to assume simple dependency mode is just how dependencies work (where system order is order of dependency)
     
  5. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    910
    What's the difference in what you call default and simple? (from code perspective)
     
  6. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,631
    Adding ENABLE_SIMPLE_SYSTEM_DEPENDENCIES will enable simple dependency mode. It'll just create a dependency chain on order of systems rather than read/write. Reduces the cost of calculating dependency chains at the cost of having less efficient job scheduling.

    It's not advised to use but there are certain projects especially on mobile with small entity counts and not great thread utilization that can benefit from it. From using it ages ago, I found the biggest issues is you really have to remove all system groups as they trigger sync points.
     
    Egad_McDad and Enzi like this.
  7. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,653
    Just small clarification as I think precise namings important in this case, this is exactly order of jobs scheduling to local queue (or forcing them to be available for worker threads if use ScheduleBatchedJobs) AND systems run. But what you meant in diagrams is jobs execution which order depends on unity dependency resolver and not on these attributes :)
     
    Egad_McDad and MNNoxMortem like this.
  8. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,631
    Yes that is an important clarification, I will edit
     
    Egad_McDad and eizenhorn like this.