My notices about ATA performance

Bruce Evans bde at
Mon Feb 7 22:40:33 PST 2005

On Mon, 7 Feb 2005, Andrey Smagin wrote:

> I have 2 PC.
> 1. iP 166 (RAM 48Mb)
> 2. Duron 1133 (RAM 1Gb)
> 2 HDD - WD and Seagate  (120GB/8Mb cache).

These newer drives shouldn't be the bottleneck, especially with older
CPUs (and motherboards?).

> Kernels used
> FreeBSD 6.0 CURRENT (1-2 week old)
> Test speed of copying 1 large (600Mb) file
> from 1 HDD to another.

To test only ATA, copy between (raw) partitions.  Using whole/large
partitions is easiest, but the i/o size doesn't need to be nearly as
large as for a file since the (FreeBSD) disk cache is not involved.

> If put HDD's on PC 1
> under 4.8  -  7-10 MBytes/s (UDMA33)(60%CPU Usage)
> under 5.1  - 2.7-3 MBytes/s (UDMA33)(100%CPU Usage)
> under 6.0  - 2.7-3 MBytes/s (UDMA33)(100%CPU Usage)

60% may be too high.  100% is too high.

Check that UDMA33 is actually enabled, and where the CPU usage is.
The latter is easier under 5.x+ using top -S.  If the problem is
interrupt overhead due to not using DMA, then it is easy to verify
using systat -v.

> If put better CPU K6-2-233 on PC 1 then speed of copying increased
> under 5.1  - 3.2-4 MBytes/s (UDMA33)(100%CPU Usage)
> under 6.0  - 3.2-4 MBytes/s (UDMA33)(100%CPU Usage)

I have a K6-1-233 handy for testing and noticed a drop loss of performance
a year or 2 ago between RELENG_4 and RELENG_5 or possibly between ATA
and ATAng on it in ATAng a year or two ago, and breakage by ATAng a
little later (see below).  I suspect the problem is loss of support
for correct DMA timing on the old VIA motherboard on this system.  The
problem may be increased by the system's drive also being old and slow:

% atapci0: <VIA 82C586B UDMA33 controller> port 0x6000-0x600f at device 7.1 on pci0
% ad0: 407MB <SAMSUNG SHD-3212A (APOLLO-4) AD> [1002/16/52] at ata0-master WDMA0
% acd0: CDROM <CS-R38 0> at ata0-slave PIO3

This drive has interesting behaviour related to DMA:
- it doesn't claim to support DMA.  It is so old (bought in 1995 as a
  cheap replacement for a failing drive?) that it doesn't support most
  of the feature bits in the ATA standard.  However, DMA used to worked
  perfectly with it using the old wd driver, provided DMA was forcibly
  configured.  IIRC, it worked OK using the ata driver too until ATAng.
  The above dmesg output shows that ata now decides to use DMA although
  the drive doesn't claim to support DMA.  However, the drive stopped
  working in DMA starting with ATAng (DMA mode gives write errors).  I
  work around this by putting the drive in PIO mode in /etc/rc.early:

% atacontrol mode 0 PIO2 PIO3

  This gives large CPU overhead instead.  About 60% for reading at the
  slow reading at the slow rate of 1MB/sec.  The drive can only do
  2MB/sec at best and gets close to that in DMA mode.

Your newer drives shouldn't have this problem, but the old motherboard

> If put HDD's on PC 2
> under 4.8 not tested
> under 5.1 - 34-41 MBytes/s (UDMA100)(~30%CPU Usage)
> under 6.0 - 33-41 MBytes/s (UDMA100)(~30%CPU Usage)

This is close to normal.  DMA mode takes very little CPU.  The slower
CPUs are overloaded by 50MB/sec disks for copying the data to and
from userland (a K6-1-233 can only copy at 40MB/sec), but they shouldn't
have 100% cpu usage for file copies at only 2.7-4MB/sec.

> Why speed of IO operations very depend from CPU power in 5x and 6.x ?

6.x has more pessimizations.  However, these should have only small
effects for disk i/o and other i/o operations that involve large (larger
than a few KB) buffers.


More information about the freebsd-performance mailing list