Optimization Questions (Nodes, Variables)

Hey there. I have several questions recently about optimization that I’ve had a hard time finding the answers to. All questions are in reference to UE5 blueprints. Thanks in advance for any insight to any of the below.

  1. How do “Switch” nodes work performance wise? Does a switch have to iterate through every option and attempt to match to the input? Is it effectively a series of nested boolean statements, or does it function differently somehow?

  2. How does the “Contains” (string) node function in comparison to the switch node? Assuming you have a list of words and are trying to check if the list contains any one of them, would that function any differently than a switch node? For the switch, does the variable type matter to performance, such switching on an enum?

  3. What overhead do nodes add? For instance, if you had two identically functioning blueprints, but one had an extra 100 nodes compared to the other, what performance difference would they be? Would 1k nodes make a difference? 10k?

  4. What is the overhead to variables, such as a boolean? Besides the binary behind it (and I suppose the name of the variable), is there any other usage metric that comes variables in general? Would 100 variables have a different impact? 1k?

  5. Is there any overhead to using a lot of local variables? Do they get created/destroyed every time a blueprint (that uses them) is loaded? Does this process have any impact?

  6. Is it realistically worthwhile to re-use variables when you can performance wise? Or is the gain so negligible that it’s not really worth putting effort into?

  7. This is more asking opinions, but when is it worthwhile to prioritize or worry about optimization when everything is running fine? Assuming optimization would just be removing a bunch of redundant nodes and connections, is it ever really necessary to do so, or would those gains be minimal?

Thank you again for any answers or insight you can provide.

In short for everything you look for, each node themself are cpp, so you can check online for most of your question. or do some simple profiling with the node Start Profile and End Profile.

Also note that, it actually the line execution between node that is slow(when compared to cpp) but the node itself is as fast as a cpp.

For example, a Contain or Split is fast as a cpp, but if you do a manual for each in the string to look for a letter, this will be expensive since there a lot of connected node between (in one tick).

Datatype when doing switch/comparison is faster for a Name compared to a String.

  1. Multiple simple variable will be negligible (i believe i read that on reddit where someone did test that).

  2. If you using local variable like Sound, Array, Actor, they still need to be put in memory so will be more costly that a Bool, Integer… , and yes whenever you call that function, it will re create them and destroy them when finished.

  3. just use as many variables you want(just avoid too much direct ref class) if you worrying about variable taking too much memory, look for Soft Reference.

  • just avoid long connected nodes (without delay) and that include a function calling another function in another bp in one tick. To solve that, we can use delay node or function timer to make them shorter connected nodes in one tick or move everything to cpp.
  • avoid loop or move them to a cpp.
  • note also if for example your BP is already placed on the level map and never be respawned, all it variables is already loaded in advance so you don’t need to worry about number of var in that case.
  • just keep in mind avoid the long connected nodes in one tick and using soft ref or level streaming. and use how many variable you want, you will get other more eating resource during your development.
2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.