Boost logo

Boost-Build :

Subject: Re: [Boost-build] B2 C++ engine development.
From: Fabien Chêne (fabien.chene_at_[hidden])
Date: 2018-10-26 12:39:48


Le jeu. 25 oct. 2018 à 19:55, Rene Rivera via Boost-build
<boost-build_at_[hidden]> a écrit :
>
> On Thu, Oct 25, 2018 at 12:41 PM Steven Watanabe via Boost-build <boost-build_at_[hidden]> 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.

That could also be the result of inline heuristics being different
between C and C++.
Anyway, glad to see some performance improvements in the pipe !

--
Fabien

Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk