0

So I found that my build is very slow with CMake when I do install. One package in particular is taking ~1:20 minutes to build and ~1:40 to install.

It's not installing terrabytes of data, and installation is just moving some files around, so I was wondering why it's so slow.

Now I found that if I build with ccache, I got faster build times even with a cold cache.

Now I looked at the install times, and the package went down to ~40 seconds install time. Still a lot considering CMake is only copying ~50MB, but considerably faster than before.

How can this be? Is there some kind of contention on files that is resolved with ccache?

CodeMonkey
  • 4,067
  • 1
  • 31
  • 43
  • 1
    80 sec build and 100 sec install: seems like you're building some parts of your project or you build parts that were not part of the original build. Are you using a multi configuration cmake generator and build 2 different configurations? Maybe you could do a verbose build/install and and check, if there are indeed files that are rebuild on install... – fabian Nov 23 '21 at 17:50
  • I'm using catkin which does god knows what with cmake underneath. – CodeMonkey Nov 24 '21 at 08:56

1 Answers1

1

It is impossible that ccache is improving matters if CMake is just moving files around, as it only invoked as a compiler.

What you will likely discover is that the install stage is actually rebuilding the entire package, and that ccache is therefore helping you, because even though you start cold, the build stage fills the cache, and then when install tries to rebuild everything AGAIN, it hits the cache.

You could try skipping the build step entirely. Just say cmake --build install and let it sort out what needs to happen before installing can happen.

Peter
  • 14,559
  • 35
  • 55
  • Thank you, I'm using catkin which is sitting on top of cmake, so I'm not sure how to call cmake --build install directly. But if this is the normal behavior I'm assuming catkin just rebuilds. – CodeMonkey Nov 24 '21 at 08:56