UDP Echo Server

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

UDP Echo Server

Boost - Users mailing list
Hi,



_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: UDP Echo Server

Boost - Users mailing list
Sorry, accidentally hit send.

I have a working version of a UDP Echo Server that listens to multiple ports and echos responses back. This implementation uses threads (one per port) and uses boost::asio and async reads and writes.

This implementation works fine with machines with multiple virtual cores, but I also need to run this on a machine that has one virtual core available. I will listen to about 10 ports at this time, but the number of ports could grow.

My questions are:
1) Should I re-write this to run on one core? We see performance issues on one core.
2) Is this a good candidate for boost::fibers? If so, what approach should I take? Still use boost::asio and async reads and writes?

I am a bit confused on which way to go with this. I would appreciate some helpful hints or guidance.

Thanks,

On Thu, Aug 24, 2017 at 6:01 PM, Mark Hieber <[hidden email]> wrote:
Hi,




_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: UDP Echo Server

Boost - Users mailing list
On Thu, Aug 24, 2017 at 6:07 PM, Mark Hieber via Boost-users
<[hidden email]> wrote:
> My questions are:
> 1) Should I re-write this to run on one core? We see performance issues on
> one core.
> 2) Is this a good candidate for boost::fibers? If so, what approach should I
> take? Still use boost::asio and async reads and writes?

If all you are doing is echoing UDP packets, then your program is
certainly not CPU or disk-bound. It will be constrained to the
performance of the network subsystem. I highly doubt that you need
more than one thread for that.

You said that you see performance issues on one core, are you sure
about that? I would double check and make doubly sure that your
measurements are accurate.

For UDP I don't see much difference between 1 port or 10, since UDP
packets are stateless. The number of ports should not matter.

You ask if you should re-write it to run on one core. That should be
easy to do without "rewriting" your entire program, just use a single
io_service and only call io_service::run from one thread. Fibers won't
be particularly helpful since you are not CPU or disk bound.

Are you running an optimized or a debug build?

Thanks
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: UDP Echo Server

Boost - Users mailing list
On Thu, Aug 24, 2017 at 9:34 PM, Vinnie Falco via Boost-users
<[hidden email]> wrote:

> On Thu, Aug 24, 2017 at 6:07 PM, Mark Hieber via Boost-users
> <[hidden email]> wrote:
>> My questions are:
>> 1) Should I re-write this to run on one core? We see performance issues on
>> one core.
>> 2) Is this a good candidate for boost::fibers? If so, what approach should I
>> take? Still use boost::asio and async reads and writes?
>
> If all you are doing is echoing UDP packets, then your program is
> certainly not CPU or disk-bound. It will be constrained to the
> performance of the network subsystem. I highly doubt that you need
> more than one thread for that.
>
> You said that you see performance issues on one core, are you sure
> about that? I would double check and make doubly sure that your
> measurements are accurate.
>
> For UDP I don't see much difference between 1 port or 10, since UDP
> packets are stateless. The number of ports should not matter.

I was going to mention and add, but for the running service aspect of
boost::asio, there's no other gain to be realized since UDP is
connectionless, IMO.

> You ask if you should re-write it to run on one core. That should be
> easy to do without "rewriting" your entire program, just use a single
> io_service and only call io_service::run from one thread. Fibers won't
> be particularly helpful since you are not CPU or disk bound.
>
> Are you running an optimized or a debug build?
>
> Thanks
> _______________________________________________
> Boost-users mailing list
> [hidden email]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users