Resonite-Issues icon indicating copy to clipboard operation
Resonite-Issues copied to clipboard

Rework & extend engine entity update system

Open Frooxius opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe.

The current system for running component updates and changes is relatively simple, which has some limitations for performance.

Describe the solution you'd like

Once the data model is reworked (see https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/702), we can leverage new capabilities of the data model to implement a new system for running component updates and achieve significantly higher performance:

  • Variable rate update buckets -- This will allow to change at what rate do each components/systems update - e.g. updating every 2, 3, 4... 10... updates -- Not all components require to be updated at full rate at all times. For example IK or dynamic bones for users that are far away still might need to update, but not at the same rate/fidelity that users who are near the user -- The components can be dynamically moved between the update rate buckets, as the requirements change. This will let the system to better balance itself to hit a particular update rate

  • Fast ECS system with continuous updates & multi-threading -- Systems that perform continuous updates through continuous drives will be able to register the updates to be handled through a highly efficient system, bypassing a lot of the data model overhead and spreading over multiple threads -- Since the data model knows that certain things update continuously, it can properly schedule events to be dispatched

  • Native multi-threading and background job updates -- Currently some subsystems (like procedural assets) implement their own system for this - they fire an update on background thread on changes and once computed fire another if there were more changes -- This will formalize this pattern and make it simple to integrate it into other components and systems -- It is ideal for systems that might take a while to compute and where it's beneficial if heavy/long calculations cause only particular thing (e.g. procedural mesh or UI) to update at lower rate, rather than freezing the entire framerate

  • Optimized dispatch for events with continuous updates -- Since the new data model will allow knowing when particular things update continuously, we can get rid of overhead of tracking these changes every frame and simply schedule dispatch of events appropriately

  • Dynamic update phase registration -- Rather than update phases being hardcoded, they will be registered dynamically based on the systems that are loaded into particular domain -- This way, different systems can register one or more update phases and have better control on the order in which they update relative to other systems

Describe alternatives you've considered

Similarly to the data model, there's not too many viable alternatives if we want to improve the engine and performance.

Additional Context

This requires https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/702 to be implemented first.

It will be the next step in major performance optimizations and offer another building block for future optimizations.

Frooxius avatar Nov 15 '23 20:11 Frooxius