Hi,
I'd like a confirmation: Am I right when I understand that the multi-threaded flow model of ICE implies that data is 'immutable' and so, when you set something in an array, you are actually getting a copy of the array with that specific element changed. Is that correct? In which case a set in array implies a copy of the array too? And if so, is there a way to avoid the copy?
(I have a single threaded logic which sets one element at a time on an array based on previous values in that array - very sequential so, and the timer shows the bottleneck is mostly in the set in array + set data which would make sense if indeed the array is copied each time - array being somewhat big i.e. 20000 integers).
What somewhat contradicts this is the time is mostly sent in Set Data (setting back the array as a variable) rather than is the set in Array Node itself.
Thanks!
Claude
set in array implies copy array?
-
claudevervoort
- Posts: 89
- Joined: 16 Oct 2009, 00:56
- Location: Montréal, QC, Canada
set in array implies copy array?
You do not have the required permissions to view the files attached to this post.
-
claudevervoort
- Posts: 89
- Joined: 16 Oct 2009, 00:56
- Location: Montréal, QC, Canada
Re: set in array implies copy array?
Actually I am seeing insert into array and set into array which takes identical input and output but Insert into Array mentions a new array is created so from that i'll derive that Set in Array is therefore not doing a copy after all. Not sure why then so much time is spent in setting back the array in set data.
Get Data (self.my_array) -> Set In Array -> Set Data (self.my_array): On some branches Set Data can take 7s! (Tree executing in Object Context)
Claude
Get Data (self.my_array) -> Set In Array -> Set Data (self.my_array): On some branches Set Data can take 7s! (Tree executing in Object Context)
Claude
-
Chris_TC
- Posts: 411
- Joined: 22 Mar 2010, 16:43
Re: set in array implies copy array?
That's strange indeed. It seems like an easy task to pick an index and set a value there.
Insert in Array can insert multiple values into arrays (inserting <<1,2>> at index 2 of <<3,3,5,5>> gives <<3,3,1,2,5,5>>), which might be why a new copy is needed.
Insert in Array can insert multiple values into arrays (inserting <<1,2>> at index 2 of <<3,3,5,5>> gives <<3,3,1,2,5,5>>), which might be why a new copy is needed.
-
grahamef
- Posts: 281
- Joined: 23 Jun 2009, 19:01
Re: set in array implies copy array?
I'm wondering whether the performance is related shifting memory around to resize the array? Do you get better results if you use Reserve Array first?
-
claudevervoort
- Posts: 89
- Joined: 16 Oct 2009, 00:56
- Location: Montréal, QC, Canada
Re: set in array implies copy array?
Actually the array is a fixed size, initialized with default value at the beginning. Then there is this sequential logic (yes, it means repeat node) which updates each element value one by one. So in an array of 20000 nodes, it can mean up to 20000 set in array followed by set data. What is odd is that the time spent is in set data, not set in array.
(I was reading in the SDK that a custom node should not - could not - modify an input element, which completely makes sense in that programming model, but would prohibit the approach I have taken of doing a lot of array changes).
Claude
(I was reading in the SDK that a custom node should not - could not - modify an input element, which completely makes sense in that programming model, but would prohibit the approach I have taken of doing a lot of array changes).
Claude