'Check Field' has huge performance hit

NodeCanvas Forums Support 'Check Field' has huge performance hit

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #10001
    Roy

    My real behaviour tree is currently taking about 0.065f seconds in MonoManager.Update() (17 objects with the same behaviour tree).

    I started de-activating links to try and find out what was giving the performance hit.
    I managed to pair it down to a ‘Condition List’ with a series of ‘Check Field’ condition tasks.
    Every ‘Check Field’ added approximately 0.07 seconds (this is for 17 objects remember).
    Thus, with the four tests I had in here, I was getting a hit of 0.027 seconds per update – it seemed completely linear as 8 tests gave 0.054 seconds.

    That means that I’m losing over a thirtieth of a second each frame.

    What can I do about this?

    #10007
    Gavalakis
    Keymaster

    Hello,

    Your track down is very correct. Amongst all Script Control tasks, CheckField/SetField is the slowest as it is using pure reflection and no delegation (fieldInfo.GetValue…), while all other script control tasks (eg CheckProperty) are faster since a delegate is created instead of using pure reflection.

    The reason CheckField/GetField does not, is that from a field you can’t create a delegate somehow (that I know of), while from a property you can, since properties do have a method representation for getter/setter.

    So with that said, there is no further optimization that can be done in CheckField & SetField tasks, unless a delegate can be created *somehow*

    So the actual solution if you definetely need to, is to use properties instead of fields 🙂

    Cheers!

    Join us on Discord: https://discord.gg/97q2Rjh

    #10006
    Roy

    Rather than use properties I chose to check a function which simply checked an enum.
    Unfortunately this did not cause any speed up either until I moved the following line from the ‘OnCheck’ function to the ‘OnInit’ function. I believe this is a valid optimization?

    args = new object[] { paramValue1.objectValue };

    #10005
    Gavalakis
    Keymaster

    Hello,

    I suspect you are using an older version than 1.5.9. The changes from pure reflection to delegates was made in 1.5.9 and as such the line of code you posted doesn’t exist in the latest version 🙂

    Please make sure to update and let me know.
    Thanks

    Join us on Discord: https://discord.gg/97q2Rjh

    #10004
    Roy

    I tried get the latest version. Do I have to pay another $60 for it or am I doing something wrong?
    Sorry to bother you but I can’t find anything in the Unity community that tells me what the procedure is.

    #10003
    Gavalakis
    Keymaster

    Hello,

    No, of course you dont have! All updates are free.

    Just open the asset store editor window in Unity and you will see all your bought assets. From there there is an update button. The window even lets you know that a newer version is alive.
    So everything is done through Unity and menu “Window/Asset Store” editor window.

    PS: Before update it’s always better to delete previous installations (meaning NodeCanvas folder) and re-import anew.
    This is a good practise for all assets. Not just NC.
    Just keep a backup for safety if you have to.

    🙂

    Join us on Discord: https://discord.gg/97q2Rjh

    #10002
    Roy

    Thanks. I something must be wrong on the Unity side then as I don’t see my bought assets. I’ll contact them.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.