coreutils
[Top][All Lists]
Advanced

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

Re: Another rfe: "cp" this time


From: Jim Meyering
Subject: Re: Another rfe: "cp" this time
Date: Wed, 02 May 2012 09:30:28 +0200

Pádraig Brady wrote:
> On 05/01/2012 05:59 PM, Pádraig Brady wrote:
>> Now many coreutils already provide such a hint to the kernel:
>> http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commit;h=47076e3c
>> But copy.c does not currently. I'm not sure why I didn't
>> do it for copy.c now, but I look into adding it.
>
> The attached seems to give another 5% speedup!
>
> $ dd bs=1MB count=200 if=/dev/zero of=file.in
>
> $ dd of=file.in oflag=nocache conv=notrunc,fdatasync count=0
> $ time ./cp-before file.in /dev/shm/; rm /dev/shm/file.in
> real    0m0.843s
> user    0m0.005s
> sys     0m0.417s
> $ dd of=file.in oflag=nocache conv=notrunc,fdatasync count=0
> $ time ./cp-before file.in /dev/shm/; rm /dev/shm/file.in
> real    0m0.856s
> user    0m0.002s
> sys     0m0.422s
>
> $ dd of=file.in oflag=nocache conv=notrunc,fdatasync count=0
> $ time ./cp-after file.in /dev/shm/; rm /dev/shm/file.in
> real    0m0.809s
> user    0m0.006s
> sys     0m0.373s
> $ dd of=file.in oflag=nocache conv=notrunc,fdatasync count=0
> $ time ./cp-after file.in /dev/shm/; rm /dev/shm/file.in
> real    0m0.804s
> user    0m0.007s
> sys     0m0.405s

Nice.  YMMV.
I see no change with a 200MB input (Fedora 17 desktop, ext4, SSD)

$ dd bs=1MB count=200 if=/dev/zero of=k
200+0 records in
200+0 records out
200000000 bytes (200 MB) copied, 0.663342 s, 302 MB/s

# Old cp
$ for i in $(seq 5); do dd of=k oflag=nocache conv=notrunc,fdatasync count=0 
2>/dev/null; env time --format=%e /p/bin/cp k /dev/shm; Rm -rf /dev/shm/k; done
0.55
0.55
0.55
0.56
0.55

# cp with FADVISE_SEQUENTIAL
$ for i in $(seq 5); do dd of=k oflag=nocache conv=notrunc,fdatasync count=0 
2>/dev/null; env time --format=%e /cu/src/cp k /dev/shm; Rm -rf /dev/shm/k; done
0.55
0.55
0.55
0.55
0.55

=======================================================
But with a 2000MiB input, I do see a 2% speedup:

$ dd bs=1MB count=2000 if=/dev/zero of=k
2000+0 records in
2000+0 records out
2000000000 bytes (2.0 GB) copied, 10.0025 s, 200 MB/s

$ for i in $(seq 5); do dd of=k oflag=nocache conv=notrunc,fdatasync count=0 
2>/dev/null; env time --format=%e /usr/bin/cp k /dev/shm; Rm -rf /dev/shm/k; 
done
5.56
5.56
5.56
5.56
5.56

$ for i in $(seq 5); do dd of=k oflag=nocache conv=notrunc,fdatasync count=0 
2>/dev/null; env time --format=%e /cu/src/cp k /dev/shm; Rm -rf /dev/shm/k; done
5.46
5.42
5.45
5.44
5.45

=======================================================
Using an older, much-used SSD on a nearly-full partition, I see a 7% speedup.
(It didn't have 2GiB free, so this uses an input that's half the size of the
one above, so at ~half the speed, each duration is in the same range.
Also, note the initial write speed is 50MB/s vs 200/300MB/s above)

$ dd bs=1MB count=1000 if=/dev/zero of=k
1000+0 records in
1000+0 records out
1000000000 bytes (1.0 GB) copied, 20.7219 s, 48.3 MB/s
$ for i in $(seq 5); do dd of=k oflag=nocache conv=notrunc,fdatasync count=0 
2>/dev/null; env time --format=%e /p/bin/cp k /dev/shm; Rm -rf /dev/shm/k; done
5.39
5.39
5.38
5.39
5.39
$ for i in $(seq 5); do dd of=k oflag=nocache conv=notrunc,fdatasync count=0 
2>/dev/null; env time --format=%e /cu/src/cp k /dev/shm; Rm -rf /dev/shm/k; done
5.01
4.99
5.00
4.99
4.97

=======================================================



reply via email to

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