LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ListBox Color Change – Runtime Differences


@altenbach wrote:

@JÞB wrote:

Some of your property nodes are incorrectly on the error wire. ...

Without quoting some of a post, it is impossible to tell which post you are replying to.

 


EVERY SINGLE ONE  of the posts with the Error chain on a tunnel through the "apply properties" For Loop!  Dammit!  Y'all are losing errors!

 

So, depending on where when and how frequently the code hits an error attempting to apply a property,  the code (rightly) slows down transitioning from the UI Thread.  Tossing an error that is then ignored on the tunnel. 

 

Bad, bad, bad! 

 

There is an Ignore Errors inside property node option  available from the right-click.   It ignores errors inside the node and reports only the first error encountered.  This option should be used in this code.


"Should be" isn't "Is" -Jay
0 Kudos
Message 21 of 33
(217 Views)

Thank you! That's some good input.


@altenbach wrote:

Here's what I would do to simplify the map handing and how to find the most frequent key.

There are some additional comments on the diagram.

 

altenbach_0-1785514567147.png

 

See if it can give you some ideas...

 


 

0 Kudos
Message 22 of 33
(201 Views)

@JÞB wrote:

@altenbach wrote:

@JÞB wrote:

Some of your property nodes are incorrectly on the error wire. ...

Without quoting some of a post, it is impossible to tell which post you are replying to.

 


EVERY SINGLE ONE  of the posts with the Error chain on a tunnel through the "apply properties" For Loop!  Dammit!  Y'all are losing errors!

 

So, depending on where when and how frequently the code hits an error attempting to apply a property,  the code (rightly) slows down transitioning from the UI Thread.  Tossing an error that is then ignored on the tunnel. 

 

Bad, bad, bad! 

 

There is an Ignore Errors inside property node option  available from the right-click.   It ignores errors inside the node and reports only the first error encountered.  This option should be used in this code.


Thanks for that info. I wasn't aware of this.

0 Kudos
Message 23 of 33
(197 Views)

Many property nodes are unlikely to generate errors at runtime. Just applying some cosmetic properties does not require rigorous error handling compared to others. I tend to just wired the error out to the next structure to suppress automatic error handing.

 

In the example I gave, I focused on the required task. It is up to the recipient to dot the t's and cross the i's and potentially break things.... 😄

 

Note that an error could also occur if the panel reference is invalid. This would not happen with this idea implemented.

0 Kudos
Message 24 of 33
(171 Views)

That performance difference is quite strange! I wonder if anyone know why that is.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 25 of 33
(160 Views)

@Yamaeda wrote:

That performance difference is quite strange! I wonder if anyone know why that is.


Basically, the MC ListBox is not the fastest control when you put a very large number of entries into it and then try to colorize all of them. In the past (LabVIEW 7.1.1), I worked on an application that had to handle and display around a million such entries. Attempting to put everything into one huge ListBox was convenient from a programming point of view, but it was obviously extremely slow, especially on ancient PC with old LabVIEW.

What I did instead was the following: I stored everything in an indexed database and displayed a ListBox without a scrollbar, containing only as many lines as could fit in the visible pane. The scrollbar was my own custom numeric vertical scrollbar placed next to the ListBox, so the user got the impression that it belonged to the ListBox, while in reality, under the hood, it did not.

Every time the user scrolled, I executed a query against the database, extracted only the portion of data that was actually visible on the screen (based on the scrollbar position), and displayed it with the appropriate colorization. This approach was extremely fast. Of course, I also handled the arrow keys, increment/decrement of the scroll bar and Page Up/Page Down functionality and so on.

As a bonus, I added the ability to filter the content, again using standard database queries. The result was very fast, but it took me about three weeks of hard work just to implement the viewer before everything worked like a charm (smooth, like Microsoft Access).

So, once you reach a certain number of entries, it makes sense to limit the displayed portion and retrieve (or colorize) only the data that is actually visible, rather than loading and handling everything at once.

Message 26 of 33
(195 Views)

@Andrey_Dmitriev wrote:

@Yamaeda wrote:

That performance difference is quite strange! I wonder if anyone know why that is.


Basically, the MC ListBox is not the fastest control when you put a very large number of entries into it and then try to colorize all of them. In the past (LabVIEW 7.1.1), I worked on an application that had to handle and display around a million such entries. Attempting to put everything into one huge ListBox was convenient from a programming point of view, but it was obviously extremely slow, especially on ancient PC with old LabVIEW.

What I did instead was the following: I stored everything in an indexed database and displayed a ListBox without a scrollbar, containing only as many lines as could fit in the visible pane. The scrollbar was my own custom numeric vertical scrollbar placed next to the ListBox, so the user got the impression that it belonged to the ListBox, while in reality, under the hood, it did not.

Every time the user scrolled, I executed a query against the database, extracted only the portion of data that was actually visible on the screen (based on the scrollbar position), and displayed it with the appropriate colorization. This approach was extremely fast. Of course, I also handled the arrow keys, increment/decrement of the scroll bar and Page Up/Page Down functionality and so on.

As a bonus, I added the ability to filter the content, again using standard database queries. The result was very fast, but it took me about three weeks of hard work just to implement the viewer before everything worked like a charm (smooth, like Microsoft Access).

So, once you reach a certain number of entries, it makes sense to limit the displayed portion and retrieve (or colorize) only the data that is actually visible, rather than loading and handling everything at once.


I don't think anyone here believes MCL's are fast. It's just that, for some reason, putting the property nodes inside the case selector with the constants has different timing than splitting them up. Not just different but drastically so.

Message 27 of 33
(181 Views)

Yes, we know that performance is not great and alternative approaches have been found.

 

The question still remains WHY nearly identical code ("Approach 1: and "Approach 2" in the OP question) show such a dramatic difference in speed. I made some wild guess above , but only somebody from the compiler team can probably give a definite answer. Very odd. 😄

Message 28 of 33
(177 Views)

@altenbach wrote:

Yes, we know that performance is not great and alternative approaches have been found.

 

The question still remains WHY nearly identical code ("Approach 1: and "Approach 2" in the OP question) show such a dramatic difference in speed. I made some wild guess above , but only somebody from the compiler team can probably give a definite answer. Very odd. 😄


Ah, this one... Oh, it’s quite simple — you already answered it yourself. Yes, it looks like constant folding. It’s sufficient to just surround the constant with a structure, and not only a case structure; a simple sequence is also enough. Then the code might slow down, by a factor of about 10–15 in this case:

issue01.png

Of course, there is no any rational reason why the second for-loop should be slower. It’s clearly a compiler issue (and sometimes hard to reproduce when the VI is created from scratch). Maybe someone from NI will take a look at this eventually, and someday it will get improved. In theory, I could run this under a debugger or profiler, but the problem is that this thread continuously switches to the UI thread on the property node (and this switch is probably being “optimized” when the constant is connected directly). In any case, this makes debugging a bit complicated. I’m not sure if it’s worth investing time here for a deeper investigation.

 
Message 29 of 33
(152 Views)

@Valduril wrote:

Approach 1 ("Fast") takes 400 ms for 1,000 entries on our systems.

Approach 2 ("Slow") takes 17 seconds for the exact same data.

We are using LabVIEW 2022 Q3.
Thanks for any idea or tip.


I had to test it myself and just had an interesting result!

Version Schnell Langsam Yamaeda

LV24Q3 32b 240ms 11,04s 185ms

LV25Q3 64b 250ms 6,67s 175ms

 

By just moving the case structure to a 'pre-loop' i got it down to 175ms (188ms in LV24). Ignoring errors on the property node made it slightly slower in LV25, but improved it some in LV24. Deferring updates looses time at these speeds. Times are fluctuating pretty much, from 160-210 ms.

Yamaeda_0-1785833066619.png

 

Adding a "only change if changed" got it down to 88ms.

 

Yamaeda_0-1785834214827.png

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 30 of 33
(108 Views)