New "Show Exec Pin" and what it does exactly

Hi Raphael,

Here’s why it was added:

The primary use case of this feature is to convert pure nodes (no exec pins) to impure node (with exec pins). When you mark a function as pure, it now means that it “defaults to a pure state”, but you can now toggle that at the call site.

Originally, “pure” was intended to be “functional pure”. In other words, they don’t modify state and are deterministic. If they were, we could employ some tricks to cache the result for a given input and avoid multiple evaluations.

The reality is that we can’t guarantee something like that. Someone can easily write a C++ function that modifies a member variable or is non-deterministic, and then incorrectly mark it as pure. GetTimeSeconds and any of the random stream functions are examples of functions that are tagged as Blueprint pure, but are not deterministic. You can’t really cache these values because they change with every call. As a result, we’re forced evaluate pure functions for every connection they have.

One of the main disadvantages of evaluating pure nodes with every connection is the performance cost that comes with it, which a lot of developers don’t realize. Pure nodes were never intended to be expensive, but that’s not something that was can control. We’ve definitely had cases where someone has written an expensive pure function. When connected to multiple pins, they could show up in perf reports. The compromise was to add this toggle to make it a little easier to control instead of writing specialized code to manually save the result to a variable.

You can also go in the other direction: make functions that default to impure to pure at the call site. However, you have to enable the project setting. Under the category, “Blueprint Project Settings”, check the “Allow conversion of impure nodes to pure ones” box. We don’t enable this by default because we don’t want to users to accidentally run into the aforementioned perf issues tied to pure nodes, but the option is there for anyone who wants to opt in.

-Dave

1 Like