CMake Performance with Open Babel

Recently, Luca made a post comparing the speed of CMake and autotools in which some timings were posted. I have to say that I am not sure I agreed with the conclusion and have had a very different experience with the projects I am involved in. As with anything your mileage may vary, and I have not looked at Wesnoth.

I think it is questionable at best to include the time it takes to build CMake, but not autotools. Seems like this is a one time cost and the build time is not that high for either. All tests were performed on my quad core Gentoo box at work. Each step is for the first cold run as would normally be the case when compiling Open Babel from source. The make step used `time make -j5` and I have listed the real time in each case.

The timings are shown in the table below. They seem somewhat similar to the experiences of the QGIS developers who made this move quite some time ago. All times shown are in seconds and are the real time reported by the time command.

  Autotools CMake
Configure time 20.39 4.79
Compile time 116.45 102.23
Install time 28.39 4.19
Total time 165.23 111.21

For those interested, on this system the total CMake compilation/installation time (cmake-gui disabled) was 1 minute and 54 seconds. The compilation/installation time for automake, autoconf, libtool, m4 was 2 minute and 14 seconds. I am not sure how relevant either of those times are, other than to show neither of them take that long to compile and install. Gentoo users/developers may or may not have CMake installed, most other developers will install the binary packages for either one and are likely to be much more interested in how well it integrates with their development environment, compile and install times.

As a developer I prefer CMake, and have been using/maintaining the CMake based build system for Open Babel for over a year now. It was originally contributed by the KDE Windows porting team, but I found that I spent less time waiting for it to do things when I was working on code too. Add to that the extras CMake comes with, such as CTest, CDash and CPack I think it makes a very attractive option for many projects. I am also hoping that it will allow Open Babel to drop maintaining a totally separate build system for MSVC.

I am sure the Open Babel autotools build system could be optimized (I never tried), but when you add in the additional benefits mentioned above, support for multiple targets such as makefiles, XCode, MSVC, Eclipse etc, one shared language/syntax for all build files and an increasingly polished competitor to autotools, I honestly think it is a sensible choice for projects to move to CMake. There are a few less well known features such as Fortran module dependency parsing that I think are fairly unique and valuable, in scientific coding at least (and I have used the Fortran module dependency parsing at least once and was pleasantly surprised).

Full disclosure: I recently accepted a job offer with Kitware, and will start in the Fall assuming all the visa paperwork falls into place. The opinions expressed here are my own. I think it is great to discuss issues like this objectively, and hope to be a part of making CMake a better build system. As with most software - there are areas that need improving.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

lu_zero on :

lu_zeroHaving things measured makes easier start to think where to improve, possibly your post will have Openbabel get a better build system either by fixing autotools or by cmake, same goes for the build time of autotools. =)

Marcus D. Hanwell on :

Marcus D. HanwellLike I said, I think it is great to look at these things objectively. To be honest, for projects like Open Babel where cross platform support is really important, CMake becomes even more attractive. The testing framework and dash boards offered by CDash are also a big plus for the projects developers to see how well their code works on all supported platforms.

Ultimately, having some competition in this area is likely to cause both projects to improve. The Boost project is also seriously considering a move to CMake from what I have seen.

Geoffrey Hutchison on :

Geoffrey HutchisonWell, Open Babel is switching to CMake instead of autotools for the 2.3 release version. For the current stable branch, we're supporting both CMake and autotools -- which is why Marcus can make the comparison.

The configure step is usually the biggest improvement for CMake over autotools for me. As a maintainer, autoconf re-runs frequently and doesn't cache as much data than CMake. So the performance improvement is a big productivity boost.

Marcus D. Hanwell on :

Marcus D. HanwellI didn't include anything other than the ./configure step in the configure portion for autotools, which was possibly an unfair comparison. This was just meant as a rough guide too, I only performed these steps once and the timings are so different that I don't think disk caching etc would help much.

There are so many other benfits to this move for many projects, that the build performance becomes a bonus. For my Gentoo centric readers the build timings are of a greater concern when projects move to CMake.

Ian Monroe on :

Ian MonroeWorking for Kitware huh? Now that you let your secret out, plan for some pokes regarding cmake questions in the fall. ;-)

I just ported TelepathyQt4 to cmake. Quite a complex thing since there was so many generated files, and I was porting to Windows at the same time.

CMake really just wins by default since automake doesn't even try to work on windows. But I also just find it a lot nicer to work with. That said its still a build system, so it still sucks. :-)

What a troll of a blog you linked to. If I was an automake-supporter I would cringe in embarrassment.

Marcus D. Hanwell on :

Marcus D. HanwellI delayed making this post until I felt I could let the secret out, the last thing I wanted was for people to feel I had deceived them. I would be highly unlikely to go and work for a company if I did not believe in their products though!

I will certainly do what I can to help. I agree with you, when working on a project that aims to support Linux, Mac OS X and Windows - build performance becomes secondary to OS support (which is very good) and that makes CMake the obvious choice. At the end of the day most of us are developers, and do not want to spend our time working on build systems. I think this is another area where CMake really wins.

You don't read many reviews raving about how nice the build system a project uses is. It is all about the program/library - what features it has, reliability, cross platform performance, speed, etc. That is what I alluded to at the end of the post - CMake can actually help with some of these when you start using CTest, CDash and CPack. I think it is good to make some objective comparisons of different solutions, assess where improvements could be made and hear about what other people in the community think.

James Pike on :

James PikeI'm a big fan of CMake and a few years ago began using it for every build system I've created, even moving lots of crap at work over to it.

One major disappointment is the clunky old fashioned language cmake provides. It feels like using visual basic.

I was very disappointed to see that Kitware did not show any interest in the lua bindings which allowed you to write cmakefiles with all the power of lua.

This is one sore point for me.. something that is great could be absolutely fantastic, but without kitware accepting that the cmake "language" is inadequate for many tasks nothing will happen.

As an example.. I rewrote a few of my common cmake macros in lua in about a quarter of the space. Cmake already saves me time and space, and it could save so much more.

Marcus D. Hanwell on :

Marcus D. HanwellI have not been lurking on the CMake mailing lists that long. Reading up on what Google found it certainly looks interesting. One always has to carefully weigh up the pros and cons of adding something as fundamental as a new language to a build system. In many ways this seems like a downfall for scons, but lua is much more self contained. I would agree that the CMake language is not the most beautiful, but in the same vein too many options can fragment a community. I saw some posts more recently about embedding a javascript language too.

I will do some reading. I will say that one attractive thing about CMake is that there is just one language to learn for the whole build system management task. The more dependencies added, the longer it takes to build and I would think this would also add to the complexity of porting to different architectures. I don't know enough about lua to comment on the size of the dependency or the cross platform support. I would imagine the situation is much better than Python for example.

David Valentim Dias on :

David Valentim DiasHow much times did you run these test? CMake is far better then autotool, but the difference is really great?

I think you should create a method for compare the timing using a n number of runs and test the difference of them using some statistic method (t-test?).

Sorry if my English is not good.

Marcus D. Hanwell on :

Marcus D. HanwellAs I said in the post the times were for "the first cold run," i.e. just one run. As the timings really are not all that close I am not sure I see that value in running multiple times. The subsequent runs would also be affected by file caching. The post was really intended as a direct comparison of what a typical developer/user would find when build a project using either tool. If you would like to perform further analysis then feel free - the source to OpenBabel is on the project page.

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA 1CAPTCHA 2CAPTCHA 3CAPTCHA 4CAPTCHA 5


You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.