Jump to content

Why is indexing conditional tunnel 3x faster than shift registers


Recommended Posts

Indexing tunnels (conditional or not) follow a preallocation strategy of filling a larger-than-initially-needed array (later cutting the unneeded elements), while the “Build Array” primitive allocates a new array of exactly the right size on each iteration.  So there is a lot fewer calls to the memory manager with an indexing tunnel.

Link to comment

 

21 hours ago, drjdpowell said:

Indexing tunnels (conditional or not) follow a preallocation strategy of filling a larger-than-initially-needed array (later cutting the unneeded elements), while the “Build Array” primitive allocates a new array of exactly the right size on each iteration.  So there is a lot fewer calls to the memory manager with an indexing tunnel.

Was aware of this but was not aware that this was also the case in initialize/replace scenarios.

More info on the subject here http://forums.ni.com/t5/LabVIEW/Why-is-indexing-conditional-tunnel-3x-faster-than-shift/m-p/3570173#M999382

Thanks :)

Link to comment
On 1/15/2017 at 2:30 PM, drjdpowell said:

Indexing tunnels (conditional or not) follow a preallocation strategy of filling a larger-than-initially-needed array (later cutting the unneeded elements), while the “Build Array” primitive allocates a new array of exactly the right size on each iteration.  So there is a lot fewer calls to the memory manager with an indexing tunnel.

I thought build array did some preallocation but not very much. I rearranged the code with manual preallocation and you had to allocate thousands and thousands of elements for it to be faster.

I had a stray thought about allocating a percent of the existing array with a baseline and tried it out. For elements 0-10000 it allocates 1000 when it runs out, then for elements 10000+ its 10% of current array size. That made it about 30% faster than the indexing terminals. But, on the other hand, who cares in this situation? This use case doesn't seem like a big performance bottleneck.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.