Windows – zip file extracts faster than copying

compressionrarwindows

System Win 7 32 bit. I am using WinRAR to extract a .rar file, but I think it is the same for any zipped files. I have:

1) SomeSourceCodeFolder.rar -> extract -> SomeDestCodeFolder

2) SomeSourceCodeFolder -> copy -> SomeDestCodeFolder

1st way is in general is much faster than the 2nd one. In my case, copying a 300mb code folder it says 45 minutes (which I only waited 5 minutes, didn't bother to finish it), but when I try to do the same with winRAR extract, it takes only about 45 seconds to finish.

Why is that? Doesn't zipped files go thru decrypt + copy to file system? shouldn't it be always slower than copying alone?

Best Answer

This perfectly makes sense for certain hardware: fast CPU, slow disk (HDD not SSD), just one disk.

The data has to be read and written. The amount of written data is the same in both cases but reading a compressed file means that less data has to be read. Furthermore it is usually much faster to read a single big file than to read a directory. This effect is bigger if there are many small files. You can reduce it by reading the directory structure into the cache so that the disk does not have to jump between the inodes and the data blocks:

# Edit: This works under Unix only
find /dir/to/be/copied -printf "" # just read the names
find /dir/to/be/copied -perm 777 -printf "" # just read the inodes

If the CPU does not slow down the data input (because deflating takes more time than reading) then extracting is faster than copying.

If you instead copy from a SSD to another device and your CPU is from stone age then copying will be faster.