2
\$\begingroup\$

Two operations:

  1. read 1 byte from disk
  2. read 1000 bytes from disk

Why exactly will they have approximately the same speed?

\$\endgroup\$
4
  • 3
    \$\begingroup\$ Because you read and write entire blocks at a time. 512 bytes I think. \$\endgroup\$
    – Oskar Skog
    May 26 '17 at 6:33
  • 3
    \$\begingroup\$ And also because the access time (position to the right cylinder) takes lot more time the reading itself. That's way reading 2 subsequent sectors (if they are subsequent of course) will take almost the same time as reading 1 sector. \$\endgroup\$ May 26 '17 at 6:44
  • 1
    \$\begingroup\$ You're assuming the 1000 bytes are sequential, if it's a spinny disk and the the 1000 bytes require reads from many locations then they won't have approximately the same speed. \$\endgroup\$
    – Colin
    May 26 '17 at 6:50
  • \$\begingroup\$ Mean seek time + mean rotational latency time + block read time = total time. The mean seek time is often far and away the largest of the three, with mean rotational latency next. You may need to read two blocks (typical block size is 512 bytes, though these days multiple blocks are tethered together into clusters as the minimum addressable unit) to solve #2, but since the block read time is so small it doesn't significantly affect the total time. \$\endgroup\$
    – jonk
    May 26 '17 at 7:06
1
\$\begingroup\$

A computer have different "layers" of memory. Each layer is faster and lighter than the previous one. When the processor ask for a block of memory, he takes a look at the first layer (very fast in therm of reading speed but very small as well). If the needed block here, the processor read it. If not, the 1st layer look at the 2nd layer and load the block if it's present, the processor read the block from the 1st layer. If not, the 2nd layer look at the 3rd etc...

enter image description here enter image description here

This is why there is almost no difference between read a byte and several at the same time, because the processor reads memory in block of byte, not in byte. However, if the processor ask for two datas coming from a different block, the require time will be different. (depending on the last commun block of those two datas)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.