On Thu, Oct 25, 2018 at 12:55 PM Rene Rivera <grafikrobot@gmail.com> wrote:
On Thu, Oct 25, 2018 at 12:41 PM Steven Watanabe via Boost-build <boost-build@lists.boost.org> wrote:
AMDG

On 10/24/2018 09:58 PM, Rene Rivera via Boost-build wrote:
> One of my goals in the future of B2 is to move the engine to something
> easier to maintain and improve. As such it's my goal to incrementally
> rewrite the engine component of B2 in C++. Yesterday I completed an initial
> step in that by having B2 compile as C++ instead of ANSI C. The code
> changes are in the "feature/cxx" branch and from outward appearances it's
> exactly the same as before except that the build scripts now invoke the C++
> compiler (only lightly tested for the compilers I have available). First
> con of this is that the executable is slightly fatter (about 20K on OSX).
> But also the first pro, it's about 4% faster.
>

Any explanation for this?  Are the build options
exactly the same other than -x c++?  The code
changes don't look significant, so is it just
that the stricter rules of C++ allow the optimizer
more freedom?  It looks like you're not linking
the C++ runtime (which was my first guess about
the binary size increase).

I think the speedup is from the stricter type rules of C++, probably constness and aliasing. But it would take way more investigation and looking at assembly to truly figure that out. And I'm not going to bother doing that :-) I don't prevent linking of the C++ runtime. But since it's not used yet I suspect it's just linked away anyway. My suspicion for size increase would be of the slightly different optimization behavior. In that it might prefer slightly larger code that performs better in many small instances.

While adding the "--debug" option for building I added LTO to the release build. And that gives an overall 11% perf improvement (with xcode 10 clang).

--
-- Rene Rivera
-- Grafik - Don't Assume Anything
-- Robot Dreams - http://robot-dreams.net