Boost logo

Boost Users :

Subject: Re: [Boost-users] [ASIO] "perf" shows overhead of function calls is very high
From: ecyrbe (ecyrbe_at_[hidden])
Date: 2012-11-16 12:15:32


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 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