1

I am trying to better understand how the type of I/O access influences the access time. Can a conventional HDD perform both random and sequential access ?

If so why would you want to keep provisions for both ? After reading this post I am getting the idea that sequential access is better than random access, how is that so ? Since in sequential access I have to traverse all the previous memory location just to arrive at my desired location. While in random access I can just "jump" to it. So random access provides all the facilities of sequential access.

Also under which situations will a HDD resort to random/sequential access ?

2 Answers 2

2

Can a conventional HDD perform both random and sequential access ?

A HDD is categorized as a random-access device. The sectors of the HDD are addressable, and a read or write operation requires specification of a sector address. A R/W operation does not depend on the location of the previous operation.

A sequential-access device, such as magnetic tape (reel or cartridge) and punched (paper or Mylar) tape, do not have addressable records or blocks. The records/blocks are position dependent, and read/write access has to start at the beginning of the medium. There are some tricks (e.g. file marks on mag tape) to allow high-speed searching, but sequential-access devices nowadays primarily exist because of data retention and cost-per-byte advantages. With the modern proliferation of HDDs and SDDs, sequential-access devices fail to deliver performance as a general-purpose storage device (e.g. for a filesystem).

If so why would you want to keep provisions for both ?

Sequential access is a natural capability of a random-access device.
Whereas a sequential-access device struggles (i.e. requires a lot of additional operations and consumes time) to perform random access.

Technically a HDD does not perform sequential access. The command interface does not have a "read next" or "write next". An explicit sector address must be specified.

After reading this post I am getting the idea that sequential access is better than random access, how is that so ?

Better in what way?
(BTW those answers are not 100% accurate.)

Some applications (e.g. a data recorder/logger or archiving a HDD) perform perfectly well with sequential access, and would not benefit at all using random access.
Some applications absolutely require random access in order to accomplish their task in a timely manner (e.g. database query or a filesystem).

Note that the typical PC has no sequential-access storage device.
In general, a random-access device has more utility than a device limited to sequential access. That's why the HDD (or SDD) (which are both random-access devices) are essential peripherals for computer mass-storage, whereas sequential-access devices such as tape are considered optional and relegated primarily to archival functions.

So random access provides all the facilities of sequential access.

Correct.

Also under which situations will a HDD resort to random/sequential access ?

The HDD, because of its command interface, always performs a random access.
In order to access the "next sequential" sector, the host computer must request the "previous sector + 1"; there is no command to "read (or write) next". Every R/W command must specify a sector address.

Note that the operating-system filesystem software will obscure this HDD trait. Most files are accessed sequentially: you start writing or reading a file at its beginning, and continue accessing the file one record or line at a time (i.e. sequentially). Copying a file is always performed by reading the source file sequentially. But study this answer to understand how the filesystem and HDD have to perform additional random accesses to accomplish this sequential copying of file contents.

How type of I/O access influences access time?

First we need to properly define HDD "access time" (since answers in that post you mentioned are inaccurate). There are several components to access time that correspond to a HDD operation:

  1. The read or write command has to be sent from the host computer to the HDD over the host-to-drive interface (e.g. SATA).
  2. The HDD controller processes the command. If a read request can be satisfied from the cache, then the sector data is already available; goto step #8. For a write request the sector data also has to be sent over, and then ECC bytes are calculated.
  3. The actual disk operation would commence with an optional seek operation.
    If the R/W head assembly is not already positioned at the requested cylinder, then a seek operation must be performed. The time interval to perform this R/W head movement operation is called the seek time. Note that the seek (i.e. the movement of the R/W heads) requires acceleration, an optional phase of max velocity and then deceleration. The speed is not constant, and seek times are not linearly in proportion to the number of cylinders traversed. These facts make most short-stroke calculations bogus.
    If the R/W head assembly is already positioned at the requested cylinder, then no seek is required and the seek time is effectively zero.
  4. Once the R/W head assembly is at the requested cylinder, the R/W head corresponding to requested track is selected.
  5. As the platters rotate "beneath" the R/W heads, the controller has to wait for the requested sector to come around. This waiting time is called the rotational latency. Unless you can predict when the controller starts the wait in relation to the rotational position of the requested sector, the average rotational latency is one half the rotation period. (The period is the inverse of rotational speed.)
  6. Once the requested sector is located, the actual read or write operation is performed. For a read operation, the bits read off the platter surface are written as bytes into a sector buffer. For a write operation, the data in the sector buffer are serialized and written to the platter surface.
  7. Once the entire sector has been read into the sector buffer (of the controller), the data is validated using the ECC. Correction is applied if necessary (a soft error). If the errors cannot be corrected, then a read retry is attempted.
  8. The R/W request is concluded by responding to the host computer with the sector data that was read or a "write OK" acknowledgement over the host-to-drive interface.

The access time would be the total elapsed time to perform all of these operations. Except for #3, seek time, and #5, rotational latency, the other operations tend to have relatively short and predictable durations in comparison to those two operations.

A random HDD access would tend to have a long access time because a seek of unknown span and a rotational latency would be required.
A sequential HDD access could have a minimal access time because no seek is likely (unless the previous access was the last sector of the cylinder) and rotational latency could be zero if the request was already queued up or the previous read performed "read ahead". If the timing of sending sequential requests to the HDD is poor (i.e. too late, missing the next sector), access times would be increased due to the rotational latency equal to a near-full rotation time. That latency would be about the same magnitude as a seek of one cylinder.

3
  • "If the R/W head assembly is already positioned at the requested cylinder, then no seek is required and the seek time is effectively zero." I dunno, that's not strictly random access, though the requirement to use absolute addressing means it's not strictly sequential either. I'd say it has elements of both, which is what you'd expect from a mechanical device. Oct 17, 2017 at 18:53
  • @MarshallEubanks "I dunno, that's not strictly random access" -- You seem to be making up your own definitions. In spite of your doubts, the concepts of random and sequential access and devices have been well established in the computer industry for decades. As for the sentence you quoted, it doesn't support whatever you're claiming. A cylinder could contain two or more tracks (and as many as 19 tracks for the SMD units that I wrote controller firmware for), so a seek has never been mandatory to perform a "random" access.
    – sawdust
    Oct 19, 2017 at 5:24
  • You yourself say "Sequential access is a natural capability of a random-access device." so it's really not clear what you're trying to argue other than general pedantry. I must have missed that sentence, because the only thing I was "claiming" is semantically identical to the quoted sentence, though perhaps worded poorly. Feb 9, 2018 at 15:05
1

Sequential access does not mean reading everything up to a point, it means reading a group of sectors or clusters one after another i.e. "sequentially".

Effectively you can think of it as one "random" access followed by a cluster of sequential accesses.

To demonstrate why sequential access is better than completely random access you need to understand what is involved in the process of reading from a disk.

When you ask the hard disk for a single cluster the drive must move the head into place and then wait for the spinning platter to rotate around so that the cluster is under the head and ready to be read. This is known as the "seek time" for the disk. For most hard disks the seek time is of the order of 9 milliseconds average.

For true random accesses (every request is for a non-sequential sector/cluster) then every request has an average 9 millisecond seek time as the head has to move and then wait for the correct sector each time, this delay severely limits overall data throughput as you have a cycle of

seek
data
seek
data
seek
data
seek
data

For 4 random reads. Assuming a 4KB read you have a minimum of 36 milliseconds of waiting (plus the negligible time to read each block) before you get the last block of data.

For a sequential access you can specify a start point and then say "carry on reading for X blocks". You no longer have to wait for the head to move or the disk platter to move under the head, the head is already in the right place for the next data block once it finishes the previous one so you just carry on reading. You effectively remove the 9 millisecond seek time between each data request.

For a sequential read you get

seek
data
data
data
data

Which gives you 9 milliseconds plus four small data transfer times for each block.

Assuming it take 1ms to read 4KB (this is a ballpark figure), this basically means for 4K reads you have a data throughput in the order of

  • 32KB in 40 ms for random reads, and
  • 32KB in 13 ms for sequential reads

So sequential reads are much faster.

SSD drives are different, they do not have a moving platter so the seek time is almost non-existent. Random accesses are essentially as fast as sequential accesses.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .