Probably a dumb question, because logically, unarchiving should be longer, especially if there is compression. But nevertheless, suddenly everything is not as simple as it seems.

What will be faster, copy the folder with files to 1GB, or unzip the archive with exactly the same files without compression.

  • Previously, when working with a flash drive did. A folder with a bunch of files was faster to archive -> copy -> unzip than just copy (: - Suvitruf
  • Archivers are different. Some unpack the archive into a temporary folder and then copy it. In general, I do not understand the tags that you hung. :) What is common between linux and winrar? - Beast Winterwolf
  • xD Yes I am,)) - Denis Safonov
  • By the way, tar does not compress files. - insolor

2 answers 2

I think it's all about I / O writing, which is usually lower than reading.

Tests

~$ du -sh test/ 5.2G test/ 

Direct copy:

 ~$ time cp -R tmp/ test/ real 0m34.953s user 0m0.084s sys 0m5.110s 

Compress, copy, unpack:

 ~$ time { tar cf tmp.tar tmp && mv tmp.tar test/ && tar xf test/tmp.tar -C test/; } real 1m1.619s user 0m0.563s sys 0m12.964s 

Copying an already compressed directory:

 ~$ time cp tmp.tar test/ real 0m26.251s user 0m0.028s sys 0m4.557s 

Calculate read / write count

For the archive:

 ~$ strace cp tmp.tar test/ 2>&1 | grep -c "read\|write" 55259 ~$ strace cp tmp.tar test/ 2>&1 | grep -c "write" 27623 

For the catalog:

 ~$ strace cp -R tmp test/ 2>&1 | grep -c "read\|write" 70955 ~$ strace cp -R tmp test/ 2>&1 | grep -c "write" 32455 

As a result, the difference between the number of entries for the directory and the package came out 4832 , which, when copied to a slow medium, can significantly increase the waiting time.

With a good CPU, it makes sense to pack everything before copying. 00

    Depends on the speed of the disk and processor. With a slow disk ( from which reading is performed) and a fast processor, it may be faster to unzip it from the archive than to copy the unwilling one.