0
Answered

First frame of flow machine slow as heck, why?

meds 3 years ago updated by Lazlo Bonin (Lead Developer) 3 years ago 1

This only happens the first time a gameobject with a flow machine is instantiated, after I deactivate/reactivate it or do whatever else it works fine.



Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
+1
Answered

Hi meds!

Bolt does a lot of "warmup" and caching the first time some of its components are used.

In this case, the overhead you highlighted is from the generic operator utility. It is used because you have a generic subtract node in one of your graphs. This utility only has to be initialized once for the entire game though. 

If you absolutely must avoid this, try checking Numeric in your subtract node. This will bypass the generic operator utility and use direct float subtraction, which is much faster. Otherwise, rest assured this is the only time this utility will be called.

Note that your graph executes much slower while Deep Profiling is enabled. This operation is usually very fast, and wouldn't take anywhere near 100ms in a build.

In the future, most of this will be optimized away with C# script generation, on which Andy is currently working!