[cmake-developers] Using reflinks during install phase

Alessandro Di Federico ale at clearmind.me
Thu May 29 08:06:28 EDT 2014


On Wed, 28 May 2014 16:17:39 -0400
Brad King <brad.king at kitware.com> wrote:

> On 05/28/2014 01:20 PM, Alessandro Di Federico wrote:
> > Hi, I'm working on a quite big project, namely LLVM. As you can
> > imagine, launching a `make install` it's quite time consuming, in
> > particular in Debug builds. However I'm using a smart file system
> > (BTRFS on Linux) which supports "reflinks", which basically means
> > that it's possible to create copy-on-write duplicate of a file,
> > without having to write the file contents again. This can be easily
> > done using `cp` (from the GNU Coreutils) with the --reflink
> > parameter.  
> 
> Neat.  How is it known when a reflink is safe (e.g. on the same
> filesystem)?  Does it just fall back to a normal copy otherwise?

Take a look at `man cp`, there's `--reflink=auto` which uses CoW when
possible or normal copy otherwise. For some reason it's not the default
in `cp`, probably because it's a bit slower since you need to check if
the underlying file system supports reflinks.

> This would likely go in the implementation of the file(INSTALL)
> command used internally by the installation infrastructure.
> See SystemTools::CopyFileAlways in Source/kwsys/SystemTools.cxx.
> That method could probably be optimized anyway.

OK, I'll come up with a patch. The only thing is that --reflink has
been introduced around 2009, in coreutils 7.6 (we are currently at
8.22). Is it OK to assume we have such coreutils or some kind of
(build-time?) detection is needed?

--
Ale



More information about the cmake-developers mailing list