Ask Your Question

Messages arriving by batches

asked 2017-10-05 11:38:36 -0500

TTDM gravatar image

updated 2017-10-05 11:42:09 -0500


My main question is : what could cause messages to be detectable by a queue by batches instead of right after they are published ?

Here are the details :

  • I publish a message at 500Hz
  • I'm checking the callback queue (=spinning) at 500Hz
  • the callback duration is < 0.1ms ( when a batch of 10 ( max queue size ) callabacks are called, it takes less then a ms )
  • using the callbackqueue->isempty() function, i can see that the CallbackQueue is empty most of the time which is not normal ( its size should be 1 (+-1) at each iteration )
  • After a variable time, the callbackqueue is no more empty ( isempty =0 ) and I receive all the messages that i should have received earlier ( in the limit of my queue ).

    All the informations i'm giving above have been verified using text outputs.If needed i can upload codes and text outputs ( but the texts output takes arround 200 lines to be meaningfull ).

I tried to test the standard ros behavior by creating 2 simple nods : 1 publisher at 500hz, 1 subscriber at 500Hz, the subscriber node code being nearly the same than in my real code and it worked as expected. At nearly each iteration, isempty = false and i receive a message.

So my question is, is there any known things could delay the detection of the send messages (or the pushing in the queue?) and be responsible for the behavior i'm experiencing ?

Thanks a lot if anyone as an idee, TTDM

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-10-05 16:13:01 -0500

See also this answer. As stated there, this is probably due to TCP/IPs Nagle's algorithm at work, which is default enabled for ROS communication and has to be explicitly disabled.

edit flag offensive delete link more


My bad for not seing it, thanks for the answer! It's quite surprising that the Nagle's Algorithm, which, according to the first 2 wikipedia lines, should mainly be applied on short messages has an undesired effect only on large messages ! I will try to look into it If i find the time. Thank again!

TTDM gravatar image TTDM  ( 2017-10-06 02:27:30 -0500 )edit

"large" and "small" are rather relative terms, so they may change over time.

gvdhoorn gravatar image gvdhoorn  ( 2017-10-06 02:28:32 -0500 )edit

Sure but the way I understand it, it should have an effect on messages in the [0, any limit] ("small") size interval, when it currently have an effect on [any limit, +inf ] ("large") size, edit : see link in answer above

TTDM gravatar image TTDM  ( 2017-10-06 03:13:17 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2017-10-05 11:38:36 -0500

Seen: 145 times

Last updated: Oct 05 '17