In the previous part of disk speed series you can see one way to test disk speed by using special options of the dd command.

In this article another utility – hdparm will be described.

What is common with the previous way of testing HDD disk performance is in it’s simplicity, meaning you only need to choose the right parameters and you need to know which HDD you want to test, and that’s pretty much all you need to know.

First you need to install the utility by executing the following commands:


root@test:~>yum install hdparm
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package hdparm.x86_64 0:9.43-5.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================================================================================================================================================
 Package                                                           Arch                                                              Version                                                                  Repository                                                             Size
==========================================================================================================================================================================================================================================================================================
Installing:
 hdparm                                                            x86_64                                                            9.43-5.el7                                                               ol7_latest                                                             83 k

Transaction Summary
==========================================================================================================================================================================================================================================================================================
Install  1 Package

Total download size: 83 k
Installed size: 152 k
Is this ok [y/d/N]: y
Downloading packages:
hdparm-9.43-5.el7.x86_64.rpm                                                                                                                                                                                                                                       |  83 kB  00:00:05     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : hdparm-9.43-5.el7.x86_64                                                                                                                                                                                                                                               1/1 
  Verifying  : hdparm-9.43-5.el7.x86_64                                                                                                                                                                                                                                               1/1 

Installed:
  hdparm.x86_64 0:9.43-5.el7                                                                                                                                                                                                                                                              

Complete!

After the utility has been install, you can execute the following commands to check available options:

hdparam -h

Next step is to decide which disk you want to test.

Similar to dd command, you can choose only one block device (either partition like for example /dev/sdb1 or the entire disk like /dev/sdb).

The same as with dd command, you need to be extremely careful and you need to understand what you are doing before executing commands presented here.

By executing the following command, we can check all available disks and to choose the right one.


root@oel75db12r2:~>lsblk 
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    0   50G  0 disk 
├─sda1        8:1    0    1G  0 part /boot
└─sda2        8:2    0   49G  0 part 
  ├─ol-root 249:0    0   44G  0 lvm  /
  └─ol-swap 249:1    0    5G  0 lvm  [SWAP]

At this stage everything is ready for testing HDD speed.

In this example I’m using external 7.2K ordinary HDD.


root@test:/run/media/test/181ff641-66ae-46b8-ad8c-0ea2f384060d/backup>hdparm -t -T /dev/sdd1

/dev/sdd1:
 Timing cached reads:   34024 MB in  1.99 seconds = 17083.05 MB/sec
 Timing buffered disk reads: 328 MB in  3.01 seconds = 109.15 MB/sec

Instead of describing what is meaning of options -t -T,  here I’m pasting description of two options used to test HDD speed from the manual page.

-t
Perform timings of device reads for benchmark and comparison purposes.
For meaningful results, this operation should be repeated 2-3 times on an otherwise inactive system (no other active processes) with at least a couple of megabytes of free memory.
This displays the speed of reading through the buffer cache to the disk without any prior caching of data.
This measurement is an indication of how fast the drive can sustain sequential data reads under
Linux, without any filesystem overhead. To ensure accurate measurements, the buffer cache is flushed during the processing of -t using the BLKFLSBUF ioctl.

-T
Perform timings of cache reads for benchmark and comparison purposes.
For meaningful results, this operation should be repeated 2-3 times on an otherwise inactive system (no other active processes) with at least a couple of megabytes of free memory.
This displays the speed of reading directly from the Linux buffer cache without disk access.
This measurement is essentially an indication of the throughput of the processor, cache, and memory of the system under test.

It is also important to describe meaning of the results of HDD test:

Timing cached reads
Timing buffered disk reads

Timing cached reads is controlled by the OS and is allocated from the installed RAM on computer to which disk under testing is attached.

Timing buffered disk reads is related to disk buffer which is quite small comparing it with physical RAM (first case), and is controlled by the HDD micro controller in HDD drive.

It means that data in the disk buffer is rarely used, which present actual HDD speed.

For File System it’s good to have caching in place, but for database load it is not, as it only consumes main computer memory (RAM) while it won’t speed up database IO operations at all (with Db load, all actions are taking place inside of several database files).

Next test is performed with NVMe flash disk:


root@test:~>hdparm -t -T /dev/nvme1n1

/dev/nvme1n1:
 Timing cached reads:   32570 MB in  1.99 seconds = 16354.79 MB/sec
 Timing buffered disk reads: 5780 MB in  3.00 seconds = 1926.39 MB/sec

Result for Timing cached reads is about 16 GB/sec while for ordinary 7200 rpm spinning HDD is 17 GB.

This is evidence that Timing cache reads depends on computer load at the moment of test (cpu/memory) and is not dependednt on HDD speed.

Such a high speed for 7200 spinning disk is also evidence that first results is not related to disk speed at all, but computer processing power.

Second value from the hdparm test is related to actual disk speed, as explained before.

If you compare test results for 7200 rpm spinning disk

Timing cached reads: 34024 MB in 1.99 seconds = 17083.05 MB/sec
Timing buffered disk reads: 328 MB in 3.01 seconds = 109.15 MB/sec

you can see that actual disk speed is 109 MB/sec, which is realistic result.

In the first part of the article on the same 7200 rpm spinning disk by using dd command:


time dd if=/run/media/jp/ext4razno/jp/test_write.img of=/dev/null bs=8k

disk speed was 115 MB/sec, which is very close to result from the test with hdparm utility.

The NVMe test is showing almost 1.9 GB/sec, and is showing superiority of the modern flash disks.

What is important to notice is the following:

1.
Utility hdparm is able to determine only read speed. Option to test writing speed is not available with this utility (unlike dd where we can test read and write speed).

2.
With hdparm it’s easy to test partition (like /dev/sdb1) or the entire disk (e.g. /dev/sdb) read speed.

3.
Purpose of both: dd and hdparm tests are only to get quick overview of what HW you have on your disposal, and to know some expected values depending of the disk types (SSD, PCIe, NVMe, 7200 rpm spinning disks etc.).

Type of disk speed measurement cannot be applied for database load.

 

In the next article, another utility that can perform database tests will be described.

 


Comments

There are no comments yet. Why not start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.