I’ve recently finished upgrading my system and got to play with a bunch of BIOS and system settings. I’ve been reminded of an issue that’s been bothering me for a while: Although my CPU and memories are now running at optimal settings, my overall performance remains pretty slow… and the culprit always seems to be the hard drive speed. Opening large directories takes a ton of time, and if the HDD is busy many programs will freeze for several seconds. I really want to fix this if possible! I’ve done a lot of research today on how I could optimize HDD performance, but haven’t found a lot of helpful info so I’m asking my questions here.
First some background on my setup. I have two Seagate drives: A 400 GB SATA2 with the root and swap partition, and a 2 TB SATA3 for the home partition. The home and root partitions are both ext4. All controllers are set to AHCI mode (no RAID). The drives are plugged into SATA3 ports on the motherboard and share the same controller… there are also two external SATA brackets connected to another controller, but nothing is plugged into those so they shouldn’t be relevant. My OS is Linux openSUSE Tumbleweed x64.
I first check dmesg to confirm that each drive is indeed running at the correct speed. One is set to 3.0 GB/s (SATA 2) whereas the other is at 6.0 GB/s (SATA 3), so this part seems to be in order.
mircea@linux-qz0r:~> dmesg | grep -i sata | grep 'link up'
2.899011] ata8: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
2.899032] ata14: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
3.016080] ata7: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
What bothers me apart from drive I/O freezing my processes is that from what I’ve read, I should be reaching practical drive speeds which are the link speed divided by 10. This means that for a SATA2 drive I should be getting 300 MB/s, whereas for a SATA3 drive I should be seeing 600 MB/s. Yet a simple test with hdparm shows that this is far from the case.
mircea@linux-qz0r:~> sudo hdparm -tT /dev/sda
/dev/sda:
Timing cached reads: 19738 MB in 1.99 seconds = 9902.31 MB/sec
Timing buffered disk reads: 220 MB in 3.01 seconds = 73.17 MB/sec
mircea@linux-qz0r:~> sudo hdparm -tT /dev/sdb
/dev/sdb:
Timing cached reads: 19256 MB in 1.99 seconds = 9657.30 MB/sec
Timing buffered disk reads: 412 MB in 3.00 seconds = 137.33 MB/sec
This is pretty confusing, especially since those speeds seem to vary a bit. Nothing else is reading / writing on the hard drive during that test.
Here are my other hdparm outputs which offer more info about the drives. I’d like to know if any of those settings appear out of the ordinary.
mircea@linux-qz0r:~> sudo hdparm /dev/sda
/dev/sda:
multcount = 16 (on)
IO_support = 1 (32-bit)
readonly = 0 (off)
readahead = 1024 (on)
geometry = 48641/255/63, sectors = 781420655, start = 0
mircea@linux-qz0r:~> sudo hdparm -i /dev/sda
/dev/sda:
Model=ST3400620AS, FwRev=3.AAK, SerialNo=9QH0AFLD
Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
BuffType=unknown, BuffSize=16384kB, MaxMultSect=16, MultSect=16
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=781420655
IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio1 pio2 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6
AdvancedPM=no WriteCache=enabled
Drive conforms to: Unspecified: ATA/ATAPI-1,2,3,4,5,6,7
* signifies the current active mode
mircea@linux-qz0r:~> sudo hdparm -I /dev/sda
/dev/sda:
ATA device, with non-removable media
Model Number: ST3400620AS
Serial Number: 9QH0AFLD
Firmware Revision: 3.AAK
Standards:
Supported: 7 6 5 4
Likely used: 7
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63
--
CHS current addressable sectors: 16514064
LBA user addressable sectors: 268435455
LBA48 user addressable sectors: 781420655
Logical Sector size: 512 bytes
Physical Sector size: 512 bytes
device size with M = 1024*1024: 381553 MBytes
device size with M = 1000*1000: 400087 MBytes (400 GB)
cache/buffer size = 16384 KBytes
Capabilities:
LBA, IORDY(can be disabled)
Queue depth: 32
Standby timer values: spec'd by Standard, no device specific minimum
R/W multiple sector transfer: Max = 16 Current = 16
Recommended acoustic management value: 254, current value: 0
DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=120ns IORDY flow control=120ns
Commands/features:
Enabled Supported:
* SMART feature set
Security Mode feature set
* Power Management feature set
* Write cache
* Look-ahead
* Host Protected Area feature set
* WRITE_BUFFER command
* READ_BUFFER command
* DOWNLOAD_MICROCODE
SET_MAX security extension
* 48-bit Address feature set
* Device Configuration Overlay feature set
* Mandatory FLUSH_CACHE
* FLUSH_CACHE_EXT
* SMART error logging
* SMART self-test
* General Purpose Logging feature set
* Gen1 signaling speed (1.5Gb/s)
* Gen2 signaling speed (3.0Gb/s)
* Native Command Queueing (NCQ)
* Phy event counters
Device-initiated interface power management
* Software settings preservation
Security:
Master password revision code = 65534
supported
not enabled
not locked
not frozen
not expired: security count
not supported: enhanced erase
Checksum: correct
mircea@linux-qz0r:~> sudo hdparm /dev/sdb
/dev/sdb:
multcount = 8 (on)
IO_support = 1 (32-bit)
readonly = 0 (off)
readahead = 1024 (on)
geometry = 243200/255/63, sectors = 3907020911, start = 0
mircea@linux-qz0r:~> sudo hdparm -i /dev/sdb
/dev/sdb:
Model=ST32000641AS, FwRev=CC12, SerialNo=9WM07W4C
Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=8
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=3907020911
IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio1 pio2 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6
AdvancedPM=no WriteCache=enabled
Drive conforms to: unknown: ATA/ATAPI-4,5,6,7
* signifies the current active mode
mircea@linux-qz0r:~> sudo hdparm -I /dev/sdb
/dev/sdb:
ATA device, with non-removable media
Model Number: ST32000641AS
Serial Number: 9WM07W4C
Firmware Revision: CC12
Transport: Serial
Standards:
Used: unknown (minor revision code 0x0029)
Supported: 8 7 6 5
Likely used: 8
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63
--
CHS current addressable sectors: 16514064
LBA user addressable sectors: 268435455
LBA48 user addressable sectors: 3907020911
Logical/Physical Sector size: 512 bytes
device size with M = 1024*1024: 1907725 MBytes
device size with M = 1000*1000: 2000394 MBytes (2000 GB)
cache/buffer size = unknown
Nominal Media Rotation Rate: 7200
Capabilities:
LBA, IORDY(can be disabled)
Queue depth: 32
Standby timer values: spec'd by Standard, no device specific minimum
R/W multiple sector transfer: Max = 16 Current = 8
Recommended acoustic management value: 254, current value: 0
DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=120ns IORDY flow control=120ns
Commands/features:
Enabled Supported:
* SMART feature set
Security Mode feature set
* Power Management feature set
* Write cache
* Look-ahead
* Host Protected Area feature set
* WRITE_BUFFER command
* READ_BUFFER command
* DOWNLOAD_MICROCODE
SET_MAX security extension
* 48-bit Address feature set
* Device Configuration Overlay feature set
* Mandatory FLUSH_CACHE
* FLUSH_CACHE_EXT
* SMART error logging
* SMART self-test
* General Purpose Logging feature set
* WRITE_{DMA|MULTIPLE}_FUA_EXT
* 64-bit World wide name
Write-Read-Verify feature set
* WRITE_UNCORRECTABLE_EXT command
* {READ,WRITE}_DMA_EXT_GPL commands
* Segmented DOWNLOAD_MICROCODE
* Gen1 signaling speed (1.5Gb/s)
* Gen2 signaling speed (3.0Gb/s)
* Native Command Queueing (NCQ)
* Phy event counters
Device-initiated interface power management
* Software settings preservation
Security:
Master password revision code = 65534
supported
not enabled
not locked
not frozen
not expired: security count
supported: enhanced erase
316min for SECURITY ERASE UNIT. 316min for ENHANCED SECURITY ERASE UNIT.
Logical Unit WWN Device Identifier: 5000c50019c655c1
NAA : 5
IEEE OUI : 000c50
Unique ID : 019c655c1
Checksum: correct
One notation that seems to be missing is the “using_dma” flag, this may indicate that DMA is disabled which would be a very bad thing. I’ve also read that certain fstab mount options may improve performance, though most parameters discussed by people remain confusing to me. This is my current /etc/fstab configuration:
/dev/disk/by-id/ata-ST3400620AS_9QH0AFLD-part1 / ext4 acl,user_xattr 1 1
/dev/disk/by-id/ata-ST3400620AS_9QH0AFLD-part2 swap swap defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0
debugfs /sys/kernel/debug debugfs noauto 0 0
usbfs /proc/bus/usb usbfs noauto 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
/dev/disk/by-id/ata-ST32000641AS_9WM07W4C-part1 /home ext4 defaults 1 2
Is there any way to improve HDD performance (especially for the root partition) or is everything as optimal as it gets? I’m planning on getting an SSD once I have the money, but until then I figured I’d check how the existing drives could be improved.