cp(1) of large files is causing 100% CPU utilization and poor transfer

From: Matthias Apitz <guru_at_unixarea.de>
Date: Sat, 2 Jan 2021 15:59:12 +0100
This is with:

# uname -a
FreeBSD c720-r368166 13.0-CURRENT FreeBSD 13.0-CURRENT #23 r368166M: Thu Dec 17 13:12:37 CET 2020     guru_at_c720-r368166:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64

I copy often large backup files to an external USB disk and hit the
following problem since updating to r368166:

A transfer with dd(1) works fast and as expected (~70M / sec):

# dd if=guru-20210102.tar.gz of=/mnt/AcerC720/backups/guru-20210102.tar.gz bs=8m
4601+1 records in
4601+1 records out
38603862368 bytes transferred in 506.778929 secs (76174956 bytes/sec)
# ls -lh guru-20210102.tar.gz
-r--------  1 root  wheel    36G  2 ene.  12:19 guru-20210102.tar.gz

When I use cp(1) what I normaly do the transfer is very poor and causes
100% CPU itilization:

# cp -p guru-20210102.tar.gz /mnt/AcerC720/backups/xxx
^C

killed after 1 minute; transfered in 1 minute:

# ls -lh /mnt/AcerC720/backups/xxx
-r--------  1 root  wheel   168M  2 ene.  15:34 /mnt/AcerC720/backups/xxx

168*1024*1024/60 = 2936012 bytes/sec   ./. 76174956 bytes/sec

Trussing the cp(1) process shows these sys calls:

# truss -p 37655
copy_file_range(0x3,0x0,0x4,0x0,0x200000,0x0)	 = 2097152 (0x200000)
copy_file_range(0x3,0x0,0x4,0x0,0x200000,0x0)	 = 2097152 (0x200000)
copy_file_range(0x3,0x0,0x4,0x0,0x200000,0x0)	 = 2097152 (0x200000)
copy_file_range(0x3,0x0,0x4,0x0,0x200000,0x0)	 = 2097152 (0x200000)
copy_file_range(0x3,0x0,0x4,0x0,0x200000,0x0)	 = 2097152 (0x200000)

The problem is unrelated to the external disk, also a copy
in the local file system shows the same transfer speed of 168M per
minute.

Is this a known issue or a regressionc ?

I see in the man page of copy_file_range(2) that this is new with
FreeBSD 13...

	matthias
-- 
Matthias Apitz, ✉ guru_at_unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub
¡Con Cuba no te metas!  «»  Don't mess with Cuba!  «»  Leg Dich nicht mit Kuba an!
http://www.cubadebate.cu/noticias/2020/12/25/en-video-con-cuba-no-te-metas/
Received on Sat Jan 02 2021 - 13:59:16 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:26 UTC