Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] async udp socket latency
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2015-07-02 06:28:56


On 2 Jul 2015 at 3:12, Andrew Hundt wrote:

> I'm having difficulty with latency when running an async asio udp socket. I
> don't have the same problems with an identical application that uses
> synchronous udp. I'm communicating with a physical device which permits a
> maximum 5ms latency for each UDP packet, and I'm currently getting a
> latency of 8ms with a std dev of 0.065ms which is surprisingly precise.

You should try your code on Linux and especially FreeBSD first. OS X
can be ... weird.

Secondly I'd ask this on both stackoverflow and the ASIO users
mailing list, as there are fewer ASIO experts here.

Thirdly, try running a busy loop on a core during the tests. I
usually fire up python in a command box, and run "while 1: pass".

I would also add that it is well known that async i/o attracts a ~15%
latency over sync i/o. If you want absolute max performance, you
create a thread per socket, and let the kernel schedule you more
efficiently. However creating thousands of kernel threads is unwise
on 32 bit platforms, and comes with substantial demands on perfect
architecture and choice and implementation of algorithms in your code
and control over the target system, but if you really absolutely need
minimum socket latency and you don't want to invest in a proprietary
userspace networking stack, it's about the only way to go. For most
demanding absolute minimum networking latency (HPC, hedge funds) they
can afford a proprietary userspace networking stack.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ 
http://ie.linkedin.com/in/nialldouglas/



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net