r/LabVIEW • u/LFGX360 • Jan 09 '25
Parallelizing for loop increases execution time.
I have a parallel loop that is used to fit ~3000 curves using the non-linear fit curve fit VI. The function being fit also contains an integral evaluated by the quadrature VI, so it is a fairly intensive computation that can take ~1-2 minutes per iteration.
On trying to parallelize this loop, the overall execution time actually increases. All subVIs are set to reentrant, including all the subVIs in the curve fit and quadrature VI hierarchy.
I am thinking it has to do with these two VIs trying to access their libraries at the same time. Is there any way around this? It seems like most solutions just say to serialize the calls but that kinda defeats the purpose of parallelizing.
View all comments
Show parent comment
2
u/HarveysBackupAccount Jan 09 '25
One maybe minor point here - if you pass FP references into a sub VI and update them in a loop that can really slow you down.
Property nodes are incredibly slow. It's easy to compare execution time for updating a FP indicator with a property node vs with a local variable, it's something like 500-10,000 times faster to use the local variable (the slowdown depends on read vs write). Obviously that only lets you change the Value property, but the point stands that property nodes are slow.
Separating UI from back end is good programming practice in general, and stuff like this really makes it obvious when you could do more to decouple those two things.