[ccache] [RFC PATCH] Use fast (copy-on-write) copies on btrfs

Egon Alter egon.alter at gmx.net
Wed Sep 17 06:04:43 MDT 2014


Am Mittwoch, 17. September 2014, 13:09:11 schrieb Egon Alter:
> Hi Tobias,
> thanks for the patch!
> Am Dienstag, 16. September 2014, 22:53:28 schrieb Tobias Geerinckx-Rice:
> > > this is a feature request. I think it would make sense to add CoW
> > > (Copy-on-
> > > Write) support for ccache (instead of using dangerous hard-links)
> > 
> > I think so too.
> > 
> > > for filesystems which support it (zfs, btrfs, more to come?).
> > 
> > I've hacked up a simple patch to do this unconditionally on btrfs on
> > Linux, silently falling back to a regular copy if the ioctl fails.
> > The implementation is btrfs-specific; ZFS doesn't seem to support file-
> > level CoW at the moment and there is no cross-fs kernel interface (yet).
> > 
> > Notes/questions:
> >   - It's been tested only by running a few 'make check's on both my
> >   
> >     native btrfs system and an ext4 loopback image. Caveat so much
> >     emptor.
> >   
> >   - I've done no performance testing at all. I hope to do so eventually,
> >   
> >     but free time is scarce. Egon? Anyone? :-)
> I did some measurements compiling the openSUSE kernel:
> git clean, dropped caches
> no ccache:         5391.75user 639.29system 31:26.27elapsed 319%CPU
> with ccache:        887.53user 289.11system 15:07.42elapsed 129%CPU
> with ccache + cow:  933.62user 318.38system 18:56.00elapsed 110%CPU
> So surprisingly, ccache + cow is slower than without cow. I can only guess
> that the compilation is IO limited in both cases and that using reflink
> instead of copy doesn't reduce it significantly for some reason (many small
> files maybe?). The filesystem was using compression (lzo) btw.

turned out that the linux kernel build system is special because it doesn't 
use the compilation result directly. It's first modified (checksum or so) and 
stored afterwards. The original result is removed after this. So this explains 
why there is no speedup in this case.

On the other hand, I tried building mesa which doesn't do these tricks, but I 
still can't see an improvement :-(

I checked that the ioctl actually succeeds, so I *think* cow is working, it 
just doesn't cause speedups as expected.


More information about the ccache mailing list