Showing posts with label performance. Show all posts
Showing posts with label performance. Show all posts

Monday, March 29, 2010

Disk reading performance with hdparm

hdparm can be used to get disk reading performance with following command line:

  • hdparm -T <dev>. Get cached disk reading performance. In fact, the page cache performance is tested.
  • hdparm -t <dev>. Get raw disk reading performance.

Implementation

hdparm -T
ioctl(devfd, BLKFLSBUF, NULL);
read(devfd, buf, READING_SIZE)
do {
seek(devfd, 0, SEEK_SET);
read(devfd, buf, READING_SIZE);
} while (/* time is not over */);

Because the data to be read is in page cache always (if READING_SIZE << memory size), the result is page cache performance.

hdparm -t
ioctl(devfd, BLKFLSBUF, NULL);
do {
read(devfd, buf, READING_SIZE);
} while (/* time is not over */);

Because the data to be read is not in page cache, and the bottleneck lies in raw disk reading speed, the result is raw disk reading performance.

reading prepare *         *         *
memory copy - -
raw disk read ++++++++ ++++++++

As in above figure, reading reparation and memory copying in testing is neglectable, especially when readahead is considered.