 |
|
I'm Using Linux
and ATA Arrays, no Stress, but IO is slow!
Oracle Tips by Mike Ault |
Don’t panic! Most LINUX kernels will take the default
ATA interface setpoints that were the “standard” when the kernel was
built (or even older ones). This can be corrected.
In LINUX there is the hdparm command which
allows you to reset how ATA drives are accessed by the operating
system. Using hdparm is simple and with it I have seen 300%
improvement in access speeds of various ATA drives. Let’s go through a
quick tuning sequence.
First, we will use the hdparm command with no
arguments but the full path to the disk device listing:
[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 = 0
The hdparm with no arguments but the disk device gives
the current settings for the disk drive. You should compare this to
the specifications for your drive. You may find that direct emmory
access (DMA) is not being used, readahead is too small, you are only
using 16 bit when you should be using 32 bit, etc.
Next, let’s do a basic benchmark of the current
performance of the drive, you do this using the hdparm –Tt option (for
all options do a “man hdparm” at the command line.
[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/sec
Now lets adjust the settings, the –c option, when set to 1 enables 32
bit IO, the –u option is used to get or set the interrupt-unmask flag
for the drive. A setting of 1 permits the driver to unmask other
interrupts during processing of a disk interrupt, which greatly
improves Linux's responsiveness and eliminates "serial port overrun"
errors. Use this feature with caution on older kernels: some
drive/controller combinations do not tolerate the increased I/O
latencies possible when this feature is enabled, resulting in massive
filesystem corruption. However most versions (RedHat 2.1 and greater)
using modern controllers don’t have this issue. The –p option is used
to autoset the PIO mode and –d is used to set or unset the DMA mode.
[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)
So we turned on 32 bit mode and set DMA to mode 0.
Let’s see the resulting performance change using our previous –Tt
option.
[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/sec
So we didn’t change the buffer-cache read timings, however, we
improved the buffered disk reads by 45%. Let’s tweak some more and see
if we can do better. The –m option sets the multi-sector IO count on
the drive. The –c option sets the 32 bit option, the –X sets the
access mode to mdma2 the –d1 option turns on direct memory access, the
–a8 option improves the readahead performance for large reads and –u1
turns on the unmasking operation described above.
[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)
So now let’s see what we have done to performance
using the –Tt option.
[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/sec
Not bad! We improved buffered cache reads by 5% and
buffered disk reads by 231%! These options can then be loaded into a
startup file to make them part of the system startup.
SEE CODE DEPOT FOR FULL SCRIPTS
 |
For more information on this topic, I recommend Don
Burleson's latest book "Oracle
Tuning: The Definitive Reference".
You can buy it direct from the publisher for 50%-off and get
instant access to the code depot of Oracle tuning scripts: |
http://www.rampant-books.com/book_1002_oracle_tuning_definitive_reference_2nd_ed.htm
 |
Expert Remote DBA
BC is America's oldest and largest Remote DBA Oracle support
provider. Get real Remote DBA experts, call
BC Remote DBA today. |
 |
|