Help with real-time performance needed

I tried using uv_fileno on a libuv handle from Sockets.jl. It gave a plausible-looking descriptor but I couldn’t get it to work with recv and it gave a -1 error each time. I don’t know how to access the actual error message (on Windows).

So I tried going back to adapting Sockets.recvfrom. I had to use a global variable to hold pass the buffer to the libuv callback function and it’s all a bit ugly so I’m not particularly happy with it but it seems to work. The performance is much better now - the CPU usage is stable at around 10%, the memory usage fluctuates less (mainly due to the display, I think) and, most importantly, it doesn’t drop data so often. There are still some dropped packets but that could be due to the OS or the ethernet adapter as they occasionally come out of order and I count that as being lost.

Thanks to everyone for their advice. What I’d like to have in the long term is:

  1. A robust, non-allocating recv instead of my hacked version
  2. A way of isolating the receive thread so it doesn’t get interrupted.

To be honest, I started using Julia a couple of years ago to do some quick prototyping and have been surprised how far I’ve managed to get. I was expecting to write my application in C++/C# and that would have been far more difficult and taken a lot longer.

2 Likes