Boost C++ Libraries: Ticket #8994: Design complexity prevents compiler optimizations https://svn.boost.org/trac10/ticket/8994 <p> While debugging my application I discovered that the compiler (gcc 4.6 with -O3) fails to optimize even the simplest Boost.Phoenix v3 expressions. For example, the following function object: </p> <pre class="wiki">phoenix::bind(&amp;media_session::set_local_description, &amp;session(), boost::cref(sdp)) </pre><p> when invoked, generates 7 (seven) nested operator()/eval calls before actually reaching the media_session::set_local_description method. This doesn't take into account any other possible overhead that I'm not seeing in the stack backtrace. Changing phoenix::bind to boost::bind reduces this backtrace to only 3 operator() calls before media_session::set_local_description is reached. </p> <p> Please, simplify the library to improve its efficiency. As a side note, the complicated design of the library also increases compile times and possibly resulting binary sizes (I haven't done any research on the latter, but I was suggested that in ticket <a class="new ticket" href="https://svn.boost.org/trac10/ticket/8820" title="#8820: Bugs: Reduce debug symbols size (new)">#8820</a>). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8994 Trac 1.4.3 Andrey Semashev Wed, 14 Aug 2013 10:34:31 GMT <link>https://svn.boost.org/trac10/ticket/8994#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8994#comment:1</guid> <description> <p> Some explanation: &amp;session() returns media_session*, and sdp is an object of a user-defined class. So there isn't any added complexity besides phoenix::bind. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Thomas Heller</dc:creator> <pubDate>Sun, 18 Aug 2013 09:27:16 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8994#comment:2 https://svn.boost.org/trac10/ticket/8994#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">worksforme</span> </li> </ul> <p> The number of observable backtraces in gdb do not give any indication about the efficiency of the library. Sure, boost.bind gets away with less. Phoenix just does more. Most of those function calls you see come out of proto. </p> <p> FWIW, tests have been conducted by the author of Boost.Local which investigated exactly those issues raised, all of them raised in this ticket could not be verified (<a href="http://www.boost.org/doc/libs/1_54_0/libs/local_function/doc/html/boost_localfunction/alternatives.html">http://www.boost.org/doc/libs/1_54_0/libs/local_function/doc/html/boost_localfunction/alternatives.html</a>). </p> Ticket