Building with Ninja instead of Make

1,569 views
Skip to first unread message

John Wiegley

unread,
Sep 26, 2012, 1:25:30 PM9/26/12
to ledge...@googlegroups.com
I highly recommend the "ninja" build utility over make, if you do frequent
rebuilds of Ledger. It's *hyper* fast at discovering which dependencies need
to be rebuilt. And since we're using CMake now, it's trivial to get working:

cd ~/Products/ledger
cmake ~/src/ledger -DUSE_DOXYGEN=1 -DUSE_PYTHON=1 -DBUILD_DEBUG=1 \
-GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON \
-DCMAKE_CXX_COMPILER:PATH=/usr/local/bin/clang++
ninja -j16 && ctest -j16

I don't quite have Ninja tied into acprep yet, that's next.

John

Alexis

unread,
Sep 26, 2012, 4:45:51 PM9/26/12
to ledge...@googlegroups.com
Hi John,
wow, ninja really does speed up built times quite a bit.

When running ctest I noticed that the following tests FAILED:
239 - RegressionTest_647D5DB9 (Failed)


The patch below fixes the regression test for me:
diff --git a/test/regress/647D5DB9.test b/test/regress/647D5DB9.test
index 7e53f23..9b6d851 100644
--- a/test/regress/647D5DB9.test
+++ b/test/regress/647D5DB9.test
@@ -11,5 +11,5 @@ P 2009/01/31 02:18:02 AAPL $4
P 3000/01/01 02:18:02 APPL $100

test bal --end 2008/12/31 -JV Equities
-2008-12-31 1500
+2008-06-30 1500
end test


Alexis

John Wiegley

unread,
Sep 26, 2012, 11:54:32 PM9/26/12
to ledge...@googlegroups.com
>>>>> Alexis <surr...@gmail.com> writes:

> wow, ninja really does speed up built times quite a bit.

What were the time differences for you?

Also, Travis discovered that you need a very recent version of CMake (I'm
using 2.8.9) for the Ninja stuff to work.

> test bal --end 2008/12/31 -JV Equities
> -2008-12-31 1500
> +2008-06-30 1500
> end test

This may be an actual regression, so I'll hold off on applying the patch until
I can take a closer look. Thanks for reporting it!

John

Martin Michlmayr

unread,
Sep 27, 2012, 4:09:10 AM9/27/12
to ledge...@googlegroups.com
* John Wiegley <jo...@newartisans.com> [2012-09-26 22:54]:
> > -2008-12-31 1500
> > +2008-06-30 1500
> > end test
>
> This may be an actual regression, so I'll hold off on applying the
> patch until I can take a closer look. Thanks for reporting it!

This is http://bugs.ledger-cli.org/show_bug.cgi?id=784 which is caused
by another commit.

--
Martin Michlmayr
http://www.cyrius.com/

John Wiegley

unread,
Sep 27, 2012, 5:46:42 PM9/27/12
to ledge...@googlegroups.com
>>>>> Martin Michlmayr <t...@cyrius.com> writes:

> This is http://bugs.ledger-cli.org/show_bug.cgi?id=784 which is caused by
> another commit.

Ok, I'm seeing that failure here too.

John

Alexis

unread,
Sep 30, 2012, 3:14:13 AM9/30/12
to ledge...@googlegroups.com
Hello John Wiegley on Thu, Sep 27, 2012 at 05:54:32AM CEST, you wrote:
> >>>>> Alexis <surr...@gmail.com> writes:
> > wow, ninja really does speed up built times quite a bit.
>
> What were the time differences for you?

Compile of vanilla next branch using make:
make -j8 622,73s user 35,79s system 655% cpu 1:40,45 total

Compile of next branch with applied patch using make:
make -j8 509,42s user 28,72s system 615% cpu 1:27,45 total

Compile of vanilla next branch using make:
ninja -j8 617,08s user 33,38s system 691% cpu 1:34,03 total

Compile of next branch with applied patch using ninja:
ninja -j8 494,93s user 26,16s system 666% cpu 1:18,15 total


When comparing the numbers I think the wow effect I perceive
comes from the new hardware I recently got ;)

I used the following patch to test recompile times:
https://raw.github.com/gist/856799/66158f9f3b732d658f5d0784407ec63a0be33746/ledger_time_colon.patch


Alexis

John Wiegley

unread,
Sep 30, 2012, 3:18:51 AM9/30/12
to ledge...@googlegroups.com
>>>>> Alexis <surr...@gmail.com> writes:

> When comparing the numbers I think the wow effect I perceive
> comes from the new hardware I recently got ;)

The biggest wow I get is when I run Ninja and only one file has changed. The
time from hitting RET to rebuild is *much* faster.

In another project running "make" with nothing to do took 0.35s, and "ninja"
took 0.008.

Plus, Ninja knows to rebuild if the make *rule* has changed, not just it's
dependencies.

John

ed

unread,
Sep 30, 2012, 5:44:20 AM9/30/12
to Ledger
I get
ledger ed$ cmake ~/src/ledger -DUSE_DOXYGEN=1 -DUSE_PYTHON=1 -
DBUILD_DEBUG=1 \
> -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON \
> -DCMAKE_CXX_COMPILER:PATH=/usr/local/bin/clang++
CMake Error: Could not create named generator Ninja


I am building directly from hand built libraries etc, i.e. not using
macports.

ed

unread,
Sep 30, 2012, 1:16:32 PM9/30/12
to Ledger
I should have said this was on OS X, Ninja seems to be disabled on
this platform because it breaks some types of builds.

John Wiegley

unread,
Oct 3, 2012, 12:00:24 PM10/3/12
to ledge...@googlegroups.com
>>>>> ed <ed.te...@gmail.com> writes:

> I get
> ledger ed$ cmake ~/src/ledger -DUSE_DOXYGEN=1 -DUSE_PYTHON=1 -
> DBUILD_DEBUG=1 \
>> -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON \
>> -DCMAKE_CXX_COMPILER:PATH=/usr/local/bin/clang++
> CMake Error: Could not create named generator Ninja

Do you have CMake 2.8.9?

John
Reply all
Reply to author
Forward
0 new messages