LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trim Whitespace.vi is not re-entrant. Why?

The "Trim Whitespace.vi" is a very useful utility and gets sprinkled all over a project.  It can be called from various simultaneous parts of a project as well as from independent top level VIs.  As such I would think that it should be re-entrant?

 

I have been seeing choppy response from two different simultaneous top level VIs and one of the shared sub-VIs is "trim whitespace".

 

This seems to just be a configuration oversight?  This utility seems to have been written long ago (~ 2002) and has been blocking execution ever since.  I have lots of CPU cores and forcing single threading seems to be unnecessary here.

LabVIEW ChampionLabVIEW Channel Wires

Message 1 of 95
(4,991 Views)

Is it faster/smoother if you make it re-entrant? At least in 2017 there's no reason I can see that you couldn't do that, although I guess that isn't the point of the question...


GCentral
0 Kudos
Message 2 of 95
(4,974 Views)

Hi sth,

 

strings are unlimited in size: using TrimWhitespace in parallel might result in huge memory consumption...

The compiler will also optimize this function to remove the different case structures inside for the op mode...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 95
(4,971 Views)

I remember reading either here or on lavag.org that the trim whitespace is used all over the place that making it re-entrant would cause LabVIEW to run out of memory, this was from AQ. If you need to use it in a tight loop then roll your own or use the primitives. The snapshot is from the Error Cluster From Error Code.vi, these are NI's comments.

 

Snap1.png

 

mcduff

Message 4 of 95
(4,947 Views)

I've never really understood what the difference is that makes Match Pattern improve performance over a regex match.  I suspect there is a caveat or two that we are missing in the help file.

 

Frankly, Trim Whitespace.vi could be improved with some code I serendipitous wrote yesterday for a similar problem.

So, Why not?Trim String.png


"Should be" isn't "Is" -Jay
Message 5 of 95
(4,943 Views)

So the point is that all of the lowest 33 ascii character codes are trimmed? With 33 being the first non-whitespace character? 

 

Is that the same behaviour as the trim whitespace VI?


GCentral
0 Kudos
Message 6 of 95
(4,940 Views)

@cbutcher wrote:

So the point is that all of the lowest 33 ascii character codes are trimmed? With 33 being the first non-whitespace character? 

 

Is that the same behaviour as the trim whitespace VI?


NO! Trim Whitespace.vi only searches ^[\t\n\r\s] and [\t\n\r\s]$  Trim String.vi attached throws out everything below "!" Other than that caveat they are very similar


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 95
(4,936 Views)

@Jeff

 

Works nicely! I will wait before I test it to see if Altenbach posts a faster solution. Smiley Very Happy

 

mcduff

Message 8 of 95
(4,934 Views)

mcduff wrote:

Works nicely! I will wait before I test it to see if Altenbach posts a faster solution. Smiley Very Happy


Nah, I am more of a "numbers" kind of guy. 😄

Message 9 of 95
(4,920 Views)

@altenbach wrote:

mcduff wrote:

Works nicely! I will wait before I test it to see if Altenbach posts a faster solution. Smiley Very Happy


Nah, I am more of a "numbers" kind of guy. 😄


A "complex" guy 😄

Message 10 of 95
(4,904 Views)