The following is part of a series on the different aspects of disk I/O performance and optimization for Oracle...
databases. Each tip is excerpted from the not-yet-released Rampant TechPress book, "Oracle disk I/O tuning," by Mike Ault. Check back to the main series page for upcoming installments.
As noted above, the -m sectcount and -u 1 options should be used with caution at first, preferably on a read-only file system. Most drives work well with these features, but a few drive/controller combinations are not 100% compatible. File system corruption may result. Backup everything before experimenting!
Some options (e.g. -r for SCSI) may not work with old kernels as necessary ioctl()'s were not supported.
Although this utility is intended primarily for use with (E) IDE hard disk devices, several of the options are also valid (and permitted) for use with SCSI hard disk devices and MFM/RLL hard disks with XT interfaces.
(The above list of parameters and notes derived from the Linux man (manual) pages)
As you can see, we can alter or control about every aspect of the ATA/IDE drive environment and report on some aspects (-r for read only status and -g for geometry, as well as the -T and -t testing parameters) of the SCSI environment on Linux using the hdparm command.
Let's go through an example disk tuning on a LINUX server using hdparm.
We have just installed a brand new 40 GB EIDE disk drive into our Linux server (aultlinux2.) Knowing about the hdparm command, we run it against the disk after we have configured it for use:
[root@aultlinux2 root]# hdparm /dev/hdb /dev/hdb: multcount = 16 (on) IO_support = 0 (default 16-bit) unmaskirq = 0 (off) using_dma = 0 (off) keepsettings = 0 (off) readonly = 0 (off) readahead = 8 (on) geometry = 77557/16/63, sectors = 78177792, start = 0This doesn't look very good. After all, this is a fairly new drive and should have lots of good features, let's do a -Tt check (give us the performance corrected for any buffering effects):
[root@aultlinux2 root]# hdparm -Tt /dev/hdb /dev/hdb: Timing buffer-cache reads: 128 MB in 1.63 seconds = 78.53 MB/sec Timing buffered disk reads: 64 MB in 14.20 seconds = 4.51 MB/secIt is as we feared, 4.51 MB/sec is very poor performance for this drive. It is supposed to give at least 10 MB/sec and usually much more! First, we will leave things as is except we will goose up the IO support from 16 bit to 32 bit (the c1 setting):
[root@aultlinux2 root]# hdparm -c1 -u0 -p -d0 /dev/hdb /dev/hdb: attempting to set PIO mode to 0 setting 32-bit IO_support flag to 1 setting unmaskirq to 0 (off) setting using_dma to 0 (off) IO_support = 1 (32-bit) unmaskirq = 0 (off) using_dma = 0 (off) [root@aultlinux2 root]# hdparm -Tt /dev/hdb /dev/hdb: Timing buffer-cache reads: 128 MB in 1.63 seconds = 78.53 MB/sec Timing buffered disk reads: 64 MB in 9.80 seconds = 6.53 MB/secWell, a 6.53/4.51*100=144.8 percent improvement with just one setting! Let's make sure it is doing a proper multi-read of 16. We know the controller is capable of DMA2 level support (mdma2), and in order to turn on DMA support, we will need to use the d1 setting and the -X setting to set the proper DMA level. While we are at it, lets set the unmask IRQ setting, so IO is enhanced.
[root@aultlinux2 root]# hdparm -m16 -c3 -X mdma2 -d1 -a8 -u1 /dev/hdb /dev/hdb: setting fs readahead to 8 setting 32-bit IO_support flag to 3 setting multcount to 16 setting unmaskirq to 1 (on) setting using_dma to 1 (on) setting xfermode to 34 (multiword DMA mode2) multcount = 16 (on) IO_support = 3 (32-bit w/sync) unmaskirq = 1 (on) using_dma = 1 (on) readahead = 8 (on) [root@aultlinux2 root]# hdparm -Tt /dev/hdb /dev/hdb: Timing buffer-cache reads: 128 MB in 1.56 seconds = 82.05 MB/sec Timing buffered disk reads: 64 MB in 4.29 seconds = 14.92 MB/secAll right! That's much better! A 14.92/4.51*100 = 330.8 percent improvement in throughput! On this one's companion drive, /dev/hda, (from a different manufacturer), we were able to get it from 2.15 MB/sec to a whopping 25.7 MB/sec (that's over 1000 percent improvement)!
You will need to add the settings to your startup scripts (usually put it in the database start or Oracle kernel configuration script you use) since they will not be retained between reboots. In addition, you should add the -K flag to retain the settings between soft resets of the drive.
Even if you are only using the ATA drives for system software and swap area, you can see where tuning them using hdparm can make a significant performance difference for your system.
Click to buy the book, "Oracle disk I/O tuning," by Mike Ault.
About the author
Mike Ault is a SearchOracle.com expert and a senior Oracle consultant with Burleson Consulting, and one of the leading names in Oracle technology. The author of more than 20 Oracle books and hundreds of articles in national publications, Mike Ault has five Oracle Masters Certificates and was the first popular Oracle author with his landmark book "Oracle7 administration and management." Mike also wrote several of the "Exam Cram" books, and enjoys a reputation as a leading author and Oracle consultant. Ask Mike a question today!