Re: Rsync on servers
otto.wyss@bluewin.ch (Otto Wyss) writes:
> Just reading bytes off a disk also need a considerable amount of CPU and
> pushing them out through a TCP/IP-Stack as well.
Where did you get that idea? Sure, on crappy nics and IDE drives, it
can take a fair bit of CPU, but even then not much compared to rsync.
> I don't believe that rsync really uses that more if you count the
> overall costs.
You're wrong. It uses vastly more user CPU time.
Here's a comparison of transfering a 10MB test file using rcp and
rsync. I send a file first where there's nothing to conflict with on
the other system. This gives us a good baseline to see how long it
should take for network traffic. Then I create a new random file and
rcp and rsync that over the old one. This gives us an idea how long
it takes to do the syncing algorithm.
Although this test sends the whole file over, we know how much CPU
time it takes to do this and can factor that out. And this is on a
machine with crappy IDE drives. PIII700, UDMA33 IDE, 100baseT 3c575
cardbus NIC.
As you can see below, when it actually has to compute whether blocks
have changed, it takes close to the same amount of system CPU (1.36x)
but vastly more user CPU. (17.8x as much!) And as time spent
rattling disks and using the NIC is counted as system time, you can
see that rsync really does use more cpu than a straight network
transmit.
Now, does it use more than ftp? I'd wager it can't use any less than
ftp. I didn't time ftp because it's more of a hassle to time, but
with a decent ftp server that uses sendfile(2), ftp will hardly use
any userspace CPU at all.
[15:14:10] wesley:~ $ dd if=/dev/urandom of=testfile bs=10240 count=1024
1024+0 records in
1024+0 records out
[15:14:25] wesley:~ $ time rcp testfile alan@devlinux:testfile.rcp
real 0m1.040s
user 0m0.000s
sys 0m0.130s
[15:14:54] wesley:~ $ time rsync testfile alan@devlinux:testfile.rsync
real 0m1.114s
user 0m0.300s
sys 0m0.440s
[15:15:03] wesley:~ $ dd if=/dev/urandom of=testfile bs=10240 count=1024
1024+0 records in
1024+0 records out
[15:15:16] wesley:~ $ time rcp testfile alan@devlinux:testfile.rcp
real 0m1.041s
user 0m0.010s
sys 0m0.090s
[15:15:20] wesley:~ $ time rsync testfile alan@devlinux:testfile.rsync
real 0m5.348s
user 0m4.000s
sys 0m0.600s
If you still believe that disk and network access predominates over
rsync's cpu access, I challenge you to come up with any test that
demonstrates it.
--
Alan Shutko <ats@acm.org> - In a variety of flavors!
Stop searching forever. Happiness is just next to you.
Reply to: