|
Boost Users : |
Subject: Re: [Boost-users] boost asio synchronous vs asynchronous operations performance
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2014-03-25 20:51:55
On 25 Mar 2014 at 14:06, Bjorn Reese wrote:
> > and used it to generate messages. My main concern is, if we are trying to
> > send messages asynchronously (in non-ioservice thread) then the performance
> > is significantly bad compare to sending the messages synchronously in the
> > connection thread (of course if more and more number of clients get added
>
> I ran your code through a profiler and it shows that the slowdown comes
> from boost::bind and boost::shared_ptr that are needed to setup the
> async operations.
If running in a debugger such that Visual Studio disables the
non-pathologically slow memory allocator, I can believe it.
Otherwise I struggle to see how these could cause the kind of figures
the OP was seeing. If AFIO can push 400k ops/sec per core, and it's
doing seven memory allocations and frees per op which include two
std::binds and two std::shared_ptr constructions and deletions, plus
a boost::future creation and deletion which is at least another
boost::shared_ptr, the maths doesn't add up that the OP is so slow.
> I also tried to change your async_server so that it does not write all
> buffers in a loop, but instead writes the next buffer from the handler.
> This yielded almost the same performance results.
>
> I also tried to omit the connection thread, so that all work is done in
> the io_service thread. Same performance results.
Very odd. How much time is spent in the kernel?
Niall
-- Currently unemployed and looking for work in Ireland. Work Portfolio: http://careers.stackoverflow.com/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