LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

When to use lossy Enqueue Element vs Regular Enqueue (non-lossy) Element?

Hello all,

 

I'm starting to do my first run with queues...running between two loops. I've seen examples using Lossy versus non-Lossy Enqueue functions, and was wondering programmatically and philosophically, when is the best time to use each one? What are the "gotchas" for going one way or the other?

 

Thank you in advance,

 

cayenne

Message 1 of 10
(5,043 Views)

Personally, I think that with queues I want every single piece of data that hits that FIFO.  So I don't use the lossy enqueue.

 

But now that I'm sitting here thinking about it, the lossy enque would be perfect for a circular buffer.  I wouldn't be using it as a messaging construct, but as a data holder.  Ok, time to go play around with some ideas...


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 10
(5,041 Views)

I had one instance where I have to use lossy Enqueue element. We run the test and mean while we have to hold a 20 second of data all the time so we keep on writing the data to the queue and once the data is overflown it will automatically remove the older data and enqueues the new data so we always have 20 second of data in the buffer and when a failure occurs we flush the 20 second data to a file so that is easy for us to analyse the error cause.

 

For the other type of normal operations like passing the data from loop to loop you can use normal enqueue elements.

 

I am not sure in persormance wise which one leads but they both have significant use.

-----

The best solution is the one you find it by yourself
Message 3 of 10
(5,038 Views)

@P Anand wrote:

I had one instance where I have to use lossy Enqueue element. We run the test and mean while we have to hold a 20 second of data all the time so we keep on writing the data to the queue and once the data is overflown it will automatically remove the older data and enqueues the new data so we always have 20 second of data in the buffer and when a failure occurs we flush the 20 second data to a file so that is easy for us to analyse the error cause.


Exactly what I meant by circular buffer.  And exactly what I was trying to code up real quick.  Glad to hear that it works well.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 10
(5,034 Views)

@crossrulz wrote:

@P Anand wrote:

I had one instance where I have to use lossy Enqueue element. We run the test and mean while we have to hold a 20 second of data all the time so we keep on writing the data to the queue and once the data is overflown it will automatically remove the older data and enqueues the new data so we always have 20 second of data in the buffer and when a failure occurs we flush the 20 second data to a file so that is easy for us to analyse the error cause.


Exactly what I meant by circular buffer.  And exactly what I was trying to code up real quick.  Glad to hear that it works well.


Great. Do you have any idea of doing benchmark between these two. It would be very good to know what is the performance difference (I haven't tried before)

-----

The best solution is the one you find it by yourself
0 Kudos
Message 5 of 10
(5,029 Views)

Due to their completely different needs, I'm not sure a benchmark would really be of any worth.  Off the top of my head, I would think that the lossy enqueue would be faster since it doesn't have to ask for more memory when its full (assuming the "regular" queue has an unlimited size while the lossy has a fixed size).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 10
(5,024 Views)

@crossrulz wrote:

Due to their completely different needs, I'm not sure a benchmark would really be of any worth.  Off the top of my head, I would think that the lossy enqueue would be faster since it doesn't have to ask for more memory when its full (assuming the "regular" queue has an unlimited size while the lossy has a fixed size).


No the size of the queue will be defined when we create the queue so its not a variation whether we use the lossy enqueue or the normal one. I don't think there will be a big difference in their performance. Anyway good to know all these. Thanks.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 7 of 10
(5,019 Views)

@P Anand wrote:
No the size of the queue will be defined when we create the queue so its not a variation whether we use the lossy enqueue or the normal one. I don't think there will be a big difference in their performance. Anyway good to know all these. Thanks.

Well, if we define the size, the enqueing should perform the same when not full.  The enqueuing for the lossy will be much faster when full because it can just act.  The regular will have to sit there until there's a spot to put the data.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 10
(5,017 Views)

@crossrulz wrote:

@P Anand wrote:
No the size of the queue will be defined when we create the queue so its not a variation whether we use the lossy enqueue or the normal one. I don't think there will be a big difference in their performance. Anyway good to know all these. Thanks.

Well, if we define the size, the enqueing should perform the same when not full.  The enqueuing for the lossy will be much faster when full because it can just act.  The regular will have to sit there until there's a spot to put the data.


Yeah there comes the timeout into play for the regular Enqueue. So we have to check by setting the timeout to zero and while generating the error the lossy enqueue may outperform the regular enqueue (Just a guess am not sure about the actual)

-----

The best solution is the one you find it by yourself
0 Kudos
Message 9 of 10
(4,995 Views)

Not just timeout. With a finite size queue the regular Enqueue Element will block until timeout or until an element is dequeued elsewhere.  If the Enqueue uses the default -1 timeout, it will block forever.

 

If the blocking enqueue is in the same structure node as the dequeue, the program will lock up.  This configuration is seen in some Queued Message Handlers, so the finite queue should not be employed in such situations unless the programmer can guarantee by design that the queue will never get full.

 

Lynn

Message 10 of 10
(4,990 Views)