4

I have always noticed that when for example a react project or a whole website for an instance whose size sums up to say 350-450 MB takes a longer time to transfer than a 2-3 GB video file or for the matter of fact any number of files that are bundled into one file like a .zip/.rar/.iso.

Some SCs :-

Transferring some react projects:- Transferring some react projects

Transferring a movie:- Transferring a movie

I scoured the web but unfortunately found no relevant posts/answers.
Maybe I didn't use the necessary keywords...idk

If possible, a detailed explanation would be really helpful :)
Even if the explanation dives into OS concepts it's cool. I just wanna know why

Jaffrey Joy
  • 106
  • 1
  • 9
  • That's because of disc fragmentation. The big file is stored in a continuous chunk in the memory. The small are stored in different places in your HDD/SSD so the CPU needs to get their address first and only then he can start transferring them. – VTodorov Nov 17 '17 at 07:57

2 Answers2

5

There is actually a lot going on behind the 'scenes' when you transfer a file:

  • Opening the original file
    • Map the path string to something the operating system actually understands
    • Security is checked (FILE_ACCESS): are you allowed to read and delete the file?
    • More security is checked (FILE_SHARE): is you are allowed, is anyone else doing something with the file?
  • Creating the new file
    • Map the path string to something the operating system actually understands
    • Again security (FILE_ACCESS): are you allowed to create a file here? And the directory above it, and above that...
    • Create the actual new file, and put it into the file system lookup table
    • Set the default file attributes
    • Disallow others to read/write/delete the new file (FILE_SHARE)
  • The actual transfer
    • Read 4k bytes
    • Write 4k bytes, and repeat
  • The original file is removed
  • Set last modified date of the new file
  • The new file is closed

I'm sure I'm already missing a ton of steps here, but I'm here to illustrate a lot of stuff is going on before and after the actual transfer. Even if the file is empty (0 bytes) we still have to do all this. That's apart from the already given answers such as fragmentation.

Caramiriel
  • 7,029
  • 3
  • 30
  • 50
0

As per https://serverfault.com/a/9743 suggested, plus writing multiple file will also need to be indexed in the indexing table. Also It will check if same file name exist. That takes time!

Faizan Saiyed
  • 804
  • 3
  • 17
  • 33
  • But zipping itself takes as much time as the transfer, although I wont deny that it's a one time job, unless you are continuously making changes to those tiny files which is true in the case of code. – Jaffrey Joy Dec 27 '18 at 12:18