Understanding how and when to use Delay Set Data


I never really looked into Delay Set Data, so I never really understood what it did. I just assumed that it delayed setting data until something else happened. What it really does is handle situations where a multi-output port is connected to multiple Set Data ports.

Consider this ICE tree. You might think that X and Y are set to the same value (10), but that’s not what happens. You end up with X=10, and Y=15.

That’s because each Set Data forces an evaluation of the branch connected to the Set Data port. So in a tree like this, where the Add output port is plugged into two Set Data ports, you get two evaluations. First when you set X, and second time when you set Y. Consequently, X is first set to 5, and then to 10, and that all happens before the value of Y is set.

What happens with this ICE tree is like what happens in this Python snippet.

X = 5
Y = 5
X = X + Y
Y = X + Y
print X
print Y
# 10
# 10

Not like this:

X = 5
Y = 5
Y = X = X + Y
print X
print Y
# 10
# 10

To get the expected results and eliminate the extra evaluation, you could change the ICE tree so that the Add node has only one connection to the Set Data. This tree will run faster, because it has one less evaluation of the Add branch.

The Delay Set Data node addresses this issue by caching (for each Set Data port connection) the values from the first evaluation of the branch, and then setting the values all at once.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s