Search Unity

[Released] Fast Update - Improve Unity Update Function Performance

Discussion in 'Assets and Asset Store' started by Cheerio, Sep 12, 2015.

  1. Cheerio

    Cheerio

    Joined:
    Aug 3, 2013
    Posts:
    19
    Fast Update on Asset Store

    profile.png


    Hey guys,

    I just wanted to share details on my asset store item Fast Update. Fast Update reduces the overhead of any Update functions you have in your code by over 80%. It doesn't actually make the code you have inside the Update function any faster but it does mean that you can have way more components with update functions.

    There are two things you need to do to use FastUpdate in your project. Number one is to have your class inherit from FastMonoBehaviour instead of MonoBehaviour and number two is to rename your Update function to FastUpdate. There is also a FastFixedUpdate and FastLateUpdate function available which are also much faster then the Unity equivalents.

    I use FastUpdate in my projects so that I don't have to worry so much about adding an Update function to my components. While using Fast Update will definitely speed up your project, you will only notice a difference in performance if you have a couple hundred updating components on mobile or closer to five hundred on pc, depending on what your target spec is.

    The asset comes with a demo scene that shows you the difference in performance between using Update and FastUpdate. It also comes will full source code in case you wanted to modify the asset.

    If you have any questions about the asset or if you've purchased the asset and are having problems setting it up or any suggestions for improvements, please post in this thread. I'm always looking to improve my assets and will be happy to hear your feedback.

    Thanks for taking the time to check Fast Update out!

    [Fast Update on Asset Store]
     
  2. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    How are you actually achieving the speed up? Do you put them in an interface and do threading on the update?
     
  3. Cheerio

    Cheerio

    Joined:
    Aug 3, 2013
    Posts:
    19
    The asset doesn't make your update code faster but it gets rid of the overhead of each of your update functions. As an example, on my pc, having 1000 components with empty Update functions costs about 0.7ms of cpu every frame even if they aren't doing anything. That's the overhead of Unity just having to iterate through all the objects to see if they're still valid before they need to be updated. If instead I change these functions to use FastUpdate, they only cost 0,1ms of cpu which gives me a little bit more breathing room with almost no work.
     
  4. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    I understand. The Update function is called even for empty object, and there's some overhead for marashaling from Unity internal to mono C#. You are doing something a little similar to this

    https://github.com/sschmid/Entitas-CSharp

    There's a lot more things in the system to do, like order of updates, threading etc. If it is just simple looping, there's a lot of improve.