RobotStudio event

Multitasking with Parallel Socket Connections - Huge delays

Options
Hello,

I am running two tasks on the IRC5 controller in parallel, with each task connecting to separate programs via TCP/IP sockets. I noticed that if I have one task with a continuous stream of data the socketing is fast, but if I have sockets streaming data in both tasks, the speed goes down considerably.

To test this, I wrote simple scripts in java which connect via a socket,send out a message, and wait for a message back, and then write to a file how long the round-trip connection took. On the RAPID side I have a simple code which creates a socket connection, waits to receive something, and whenever it does, sends out a message. I put the same RAPID script, with different port numbers for the sockets, in my two controller tasks, and ran two separate java processes to connect to these and record how long each communication loop takes. I am running this on my local machine with the simulated controller in RobotStduio.

For running the tasks one at a time, I get an average time of less than 1ms (~0.3ms)
For two completely independent tasks running simultaneously, the delay jumps to 14ms.

Why does this happen? Is there a setting that I can change to prevent this degradation in speed? Thank you for any help!

Comments

  • Kienan123
    Kienan123
    edited September 2022
    Options
    This is an old post but figured I would add a response for others. 

    TCP has several built in items to build a stable connection with a constant heart beat. Such as to know if the connection was dropped. The Rapid pointer is basically  bouncing back and forth between task waiting for a response.

    To fix this you can add a priority to the task manager which will reduce the delay in one task TCP communication.

    -Name "T_ROB4" -Task_in_forground "T_ROB1"

    You can also use UDP communication instead which will reduce the delay in both task.