CodeMonkey
CodeMonkey

Reputation: 4738

CMake install very slow, but much faster with ccache

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?

Upvotes: 0

Views: 1772

Answers (1)

Peter
Peter

Reputation: 14937

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.

Upvotes: 1

Related Questions