Real-time topic publishing

4 posts / 0 new
Last post
ces
Offline
Last seen: 9 years 7 months ago
Joined: 07/08/2014
Posts: 2
Real-time topic publishing

Hi,

I'm using a real-time thread under Windows in which I publish 10ms media samples at various 10ms periods (e.g. some at 10ms, some using two packets at 20ms periods etc). I'm trying to publish multiple streams from this real-time thread and require that there is no delay to publishing the data - i.e. that I call FooDataWriter->write() and the call completes in minimal time. However I can frequently see the call taking several (5-6) ms to complete.

My hypothesis is that my asynchronous publishing thread (as I'm using Asynchronous publish mode for all datawriters) is kicking in and taking a semaphore required by the writer before the RT thread starts. I can see that the two threads share at least one mutex in the EventJobDispatcher, so this appears possible.

Is there any way to stop this happening? I've tried using Synchronous publishing mode for the real-time topics but this doesn't seem to speed things up, and the documentation for Async mode states that write() is faster and more deterministic.

Any suggestions appreciated.

Chris

Offline
Last seen: 3 years 1 week ago
Joined: 01/15/2013
Posts: 94

Hi,

Not sure how much I can help with your description, but here are a couple of questions:

  • Are you using the same Publisher for writing all the different media streams (Topics)? Beware that write() operations for Writers belonging to the same Publisher are serialised, they are not executed concurrently. This can affect the concurrency of the system.
  • How big are the media samples you're publishing? Media samples tend to be very big. If the subscribing (reliable) DataReaders get their buffers full, the writing operations may block. You should make sure that your data consumers (DataReaders) consume the media samples fast enough with respect to the writers. If you're not using RELIABLE reliability in your DataWriters then this doesn't affect you at all.

Hope this helps in any way.

Thanks,

Juanlu

ces
Offline
Last seen: 9 years 7 months ago
Joined: 07/08/2014
Posts: 2

Thanks for the help.

  • I'm not using reliable QoS for the media - best efforts being used here. I've also tried setting the max_blocking_time of the reliability QoS to zero and this makes no difference, therefore I'm sure this isn't a buffering issue.
  • The same (implicit) publisher is indeed being used for all topics. I can try increasing the number here - suggest one dedicated publisher for the real-time topics? I presume that each new publisher will create its own thread for async publishing, so I shouldn't create one publisher per topic (for instance).

Cheers,

Chris

Gerardo Pardo's picture
Offline
Last seen: 1 day 12 hours ago
Joined: 06/02/2010
Posts: 601

Hi Chris,

Yes each Publisher has separate threads and separate Mutexes so it is advisable you separate the real-time Topic DataWriters into a separate Publisher.

Incidentally each Subscriber also has separate mutexes so it would also seem advisable to place the real-time Topic DataReaders into a separate Subscriber.

That said I do not have a good explanation for what you are seeing. Your guess sounds certainly plausible. Here are some questions that may help narrow down the causes of what you see: How much data are you writing each 10 ms cycle and how big is each message? What percentage of the CPU is being used? How many cores do you have? How is your OS scheduler configured? I read that the quantum that the Windows kernel assigns to a thread is affected by the OS configuration. Have you determined that your windows configuration supports determimistic millisecond-level context switching?

Gerardo