Minimal summary of disk I/O

  From a physical point of view, traditional mechanical disks generally contain one or more circular disks , and each disk has two sides, called a disk surface . There is a rotating shaft (spindle) passing through the center of each disk, and all disks rotate around the rotating shaft.
  The surface of each disc is logically divided into multiple concentric rings, called tracks . The outermost track is called track 0. The track number increases in the direction of the center of the circle, and the data is stored on the track.
  If there are multiple discs, then the disc surface of each disc will be divided into tracks of the same number and specifications, and the tracks with the same number in all disc surfaces form a cylinder in space, which is called a cylinder .
  On the basis of the track, it is further divided into multiple arcs, and each arc is called a sector . A sector is the smallest physical storage unit of a disk, basically 512KB.
  There is a mechanical arm rod beside the disk, and the two are connected by a magnetic arm. One end of the magnetic arm is connected to the mechanical arm rod, and the other end contains the same number of magnetic heads as the disk surface, and the magnetic head is against the disk surface.
Mechanical hard disk

Note: The structure described here is a traditional mechanical hard disk. For high-efficiency solid-state hard disks, there are not so many mechanical components, mainly relying on chips to store data, and the access efficiency is much higher than that of mechanical hard disks.

  Reading disk data relies on mechanical movement, and the time spent in each reading is seek time + rotation delay time + transmission time . among them:

  • Seek time refers to the time it takes for the head to move to the specified track driven by the magnetic arm
  • After the magnetic head reaches the designated track, the sector to be read rotates to the magnetic head through the rotation of the disk . This period of time is called the rotation delay time (the disk rotation speed n revolutions/min refers to the rotation speed of the disk)
  • Transmission time refers to the time it takes to read (or write) from the disk

  The consumption of the entire disk I/O is mainly concentrated in the seek time and rotation delay time, and the transmission time is relatively negligible.

  As mentioned earlier, the sector is the smallest physical unit of disk storage, but the operating system does not use sectors as the unit when operating the disk, but combines several adjacent sectors to form a disk block (or called Disk cluster ), the size of the disk block is 2^n (n>=0) times of the sector, and the disk block is the basic unit of the operating system to operate the disk .
  Since disk I/O efficiency is extremely low compared to memory, in order to minimize disk I/O operations, the operating system generally adopts a pre-reading method. The size of read-ahead is generally an integer multiple of a page, which is the smallest unit of operating system memory operations. The size of a page is usually 2^n (n>=0) times the disk block size (usually 4KB).
  When the data to be read by the program is not in the memory, it will trigger a page fault exception, and then the operating system will initiate a read to the disk: read one or several pages from the beginning of the data to the memory continuously. For use by the program.
  Why do you need pre-reading? According to the principle of locality, when a piece of data is used, there is a high probability that the nearby data will be used immediately, and the efficiency of reading from a given block later is still OK, because there is no need for seek time, only consumption Very short rotation time. This phenomenon is very important for many disk-dependent systems, typically MySQL indexes.

Guess you like

Origin blog.csdn.net/huangzhilin2015/article/details/115222049