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

Re: Speedup cp command?



Hi,

Richard Owlett wrote:
> I used
>   cp -R /media/cdrom0 /media/richard/myrepository/dvd_1
> It gave me what I wanted [*N.B.* I did not want dvd_1.iso]
> It was SLOW.

An average DVD+RW can be read at about 10 MB/s average speed.
That would be about 7 minutes.
Reading usually is slower in the inner area and faster outwards.

A major slowdown is caused scattered random access. The optical head
moves to a new position quite slowly and often loudly.
Copying the plain ISO image does not involve random access.
Random access on hard disk or in RAM is much faster.


So an intermediate .iso might be the fastest vanilla way to get the
data from medium to disk.
Depending on your disk speed and RAM luxury, the additional cp -r for
unpacking might still end before a plain cp -r would have ended.

  blocks=$(expr $(/sbin/isosize /dev/cdrom) / 1024 / 1024 + 1)
  mkdir /media/richard/myisos
  dd if=/dev/cdrom bs=1M count=$blocks of=/media/richard/myisos/dvd_1.iso
  mkdir /mnt/iso
  mount -o loop /media/richard/myisos/dvd_1.iso /mnt/iso
  cp -r /mnt/iso /media/richard/myrepository/dvd_1
  umount /mnt/iso
  rm /media/richard/myisos/dvd_1.iso


If you do not have buffer space for the ISO or want to avoid the
intermediate steps, try this:

  xorriso -osirrox on:sort_lba_on:auto_chmod_on \
          -indev /dev/cdrom \
          -extract / /media/richard/myrepository/dvd_1

My measurements with DVD+RW on drive LG GH24NSC0:

  dd to .iso:   333 s

  cp -r     :  1084 s despite lots of RAM ! Miserable noises from drive.

  osirrox   :   342 s with "sort_lba_on" which lets it read with
                      monotonically ascending block addresses.

                661 s without "sort_lba_on". Clonks less than cp -r.


debian-cd could get a file arrangement which is more friendly to copiers
if it would use a newer version of xorriso.
A discussion on reproducible-builds a year ago yielded that the file
content sorting order by libisofs did not match the sorting order of
directory records in the tree. This was fixed by release 1.4.2.

Nevertheless it turns out that the layers of Debian GNU/Linux 8 still
do a poor job. I repacked the ISO by xorriso-1.4.5 and verified that
the data extents are sorted according to the sorting of the ECMA-119
and Rock Ridge tree. Simple tree traversal or alphabetically sorted
tree traversal would yield smooth reading, but cp -r has different ideas
about sequence.

  cp -r                   :  998 s  still clonking terribly.

  osirrox without sort_lba:  356 s  working smoothly.

(xorriso-1.4.6 is planned to come soon with more changes proposed by
 reproducible-builds. So i do not prod debian-cd now.)


Have a nice day :)

Thomas


Reply to: