Boost logo

Boost Users :

Subject: Re: [Boost-users] [ASIO] "perf" shows overhead of function calls is very high
From: Junchang Wang (junchangwang_at_[hidden])
Date: 2012-11-18 20:29:10


Hi Ecyrbe,

Thank you so much.I'll give it a try.

--Junchang

On Fri, Nov 16, 2012 at 12:15 PM, ecyrbe <ecyrbe_at_[hidden]> wrote:

> 2012/11/15 Junchang Wang <junchangwang_at_[hidden]>
>
>>
>> I printed out the call stack (attached at the tail of this email). It
>> seems for a single packet processing there are more than 30 function calls
>> within Boost. Can that explain why the CPU time on function calls is so
>> high? Are there some ways to avoid this kind of cost?
>>
>>
> It's the price to pay for ASIO abstraction. But, compiling with -O3 should
> inline some calls, what you see is debugging not inlined code.
>
> you can try to reduce the call stack with gcc parameter "-finline-limit="
> and try various numbers to see if it reduces function calling times.
>
> Another way to reduce this is by using your compiler optimised std::bind
> and std::function. Sometimes they are more efficient than the one provided
> by boost. (and maybe change all occurences of "boost::bind" /
> "boost::function" in boost.asio with their "std" alternative.
>
> You can also check that your compiler is c+11 compliant and implement
> perfect forwarding and try to pass your parameters by reference where it is
> possible to lower copying cost with multiple function calls.
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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