bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

suggestion - diff + patch


From: Stefanos Harhalakis
Subject: suggestion - diff + patch
Date: Sat, 1 Nov 2003 15:40:10 +0200
User-agent: KMail/1.5.9

Hi there...

There is a functionality that I want to suggest for the install program 
contained in coreutils. I believe that it should have an option to compare 
source and destination files before replacing the destination.

I've implemented this as a wrapper script and I'm using it for about half a 
year without any problems and I realy believe that the install program should 
have this feature as built-in.

It is very usefull for people that do a lot of compiling since it prevents 
makefile dependencies to fail because of header files beeing overwritten over 
and over again. It also reduces filesystem writes a lot and leads to smaller 
incremental backups.

Example: KDE is distributed in many source packages where each one depends on 
others. Reinstalling kdelibs means that all other packages will have to be 
rebuild from the scratch.. In other words, if you have already compiled and 
installed kdelibs and kdebase and you 'make install' again in kdelibs, 
kdebase will require a rebuild since most header files will be modified (just 
the [cm]time). If the install program was checking for content before 
overwritting a file this whould be avoided.

I'm attaching a patch for this. Use and modify it under GPL if you like...

Some benchmarks:

hell:/tmp/coreutils-5.0/src$ sync ; time /bin/sh -c ' cnt=0; while [ $cnt -lt 
10 ] ; do ./ginstall ~/tmp1 ~/tmp2 ; let cnt++; done'
real    0m14.860s
user    0m0.305s
sys     0m10.576s

hell:/tmp/coreutils-5.0/src$ sync ; time /bin/sh -c ' cnt=0; while [ $cnt -lt 
10 ] ; do ./ginstall ~/tmp1 ~/tmp2 ; let cnt++; done'
real    0m18.617s
user    0m0.270s
sys     0m10.627s

hell:/tmp/coreutils-5.0/src$ sync ; time /bin/sh -c ' cnt=0; while [ $cnt -lt 
10 ] ; do ./ginstall -C ~/tmp1 ~/tmp2 ; let cnt++; done'
real    0m9.559s
user    0m4.981s
sys     0m3.653s

hell:/tmp/coreutils-5.0/src$ sync ; time /bin/sh -c ' cnt=0; while [ $cnt -lt 
10 ] ; do ./ginstall -C ~/tmp1 ~/tmp2 ; let cnt++; done'
real    0m9.925s
user    0m4.995s
sys     0m3.656s

Tested on my system with a 50MB test file. Notice the delay when not using 
-C... On the second test the real time is 7 seconds more than user+sys and it 
is caused by kjournald which takes a lot of cpu time when not using -C.

I believe that a faster implementation is possible by using mmap() to compare 
source and destination files but I don't know anything about portability when 
using mmap(), so I've used open()/read().

Also I've not used O_LARGEFILE because a quick grep for it in coretuils-5.0 
returned no results.

<<V13>>

Attachment: install-compare-patch.diff
Description: Text Data

Attachment: pgpuWHXwcNk2k.pgp
Description: signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]