Jan 232013
 

During a recent install of FreeBSD 9.1 onto a gmirror, it was pointed out that my disk partitions were not aligned. Today, I’ll look at how that affects performance, both before and after alignment.

Last night, I installed FreeBSD 9.1 onto a separate HDD, which I’ll use as a floater. I can attach this HDD to any system I need to work on without booting from the main HDD. In attached this HDD to the new server so I could look at the installed HDD. Here is what I found:

$ gpart show ada1 ada2 
=>       63  488397105  ada1  MBR  (232G)
         63       4095        - free -  (2M)
       4158  488392947     1  freebsd  [active]  (232G)
  488397105         63        - free -  (31k)

=>       63  488397105  ada2  MBR  (232G)
         63       4095        - free -  (2M)
       4158  488392947     1  freebsd  [active]  (232G)
  488397105         63        - free -  (31k)

As you can see here, the FreeBSD partition starts at 4158, which is probably not on a physical sector, unless the HDD has some odd numbering system I am not familiar with.

Just what are these HDD?

ada1 at ahcich1 bus 0 scbus1 target 0 lun 0
ada1: <ST250DM000-1BD141 KC45> ATA-8 SATA 3.x device
ada1: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
ada1: Command Queueing enabled
ada1: 238475MB (488397168 512 byte sectors: 16H 63S/T 16383C)
ada1: Previously was known as ad6
ada2 at ahcich2 bus 0 scbus2 target 0 lun 0
ada2: <WDC WD2500AAKX-08ERMA0 19.01H19> ATA-8 SATA 3.x device
ada2: 300.000MB/s transfers (SATA 2.x, UDMA5, PIO 8192bytes)
ada2: Command Queueing enabled
ada2: 238475MB (488397168 512 byte sectors: 16H 63S/T 16383C)
ada2: Previously was known as ad8

NOTE: both drives mention 3.x devicebut then say SATA 2.x on the next line. What’s up with that?

Perhaps it is because the motherboard does only SATA 2.

ada1 is a ST250DM000-1BD141, otherwise known as a Seagate Barracuda ST250DM000 250GB 7200 RPM 16MB Cache SATA 6.0Gb/s 3.5″. The data sheet says it has 512 byte sectors.

ada2 is a WDC WD2500AAKX-08ERMA0, which is a Western Digital WD Blue WD2500AAKX 250GB 7200 RPM 16MB Cache SATA 6.0Gb/s. The spec sheet does not state a sector size. Hmmm.

OK. Let’s start the tests. This one took 4.5 hours

$ sudo ./phybs -rw -l 1024 /dev/ada1
   count    size  offset    step        msec     tps    kBps

  131072    1024       0    4096     2032548      64      64
  131072    1024     512    4096     2096942      62      62

   65536    2048       0    8192      898654      72     145
   65536    2048     512    8192      795774      82     164
   65536    2048    1024    8192      852636      76     153

   32768    4096       0   16384       99953     327    1311
   32768    4096     512   16384      369648      88     354
   32768    4096    1024   16384      472211      69     277
   32768    4096    2048   16384      475392      68     275

   16384    8192       0   32768       89769     182    1460
   16384    8192     512   32768      197861      82     662
   16384    8192    1024   32768      289654      56     452
   16384    8192    2048   32768      275401      59     475
   16384    8192    4096   32768       64115     255    2044
$ 

Let’s try ada2:

$ sudo ./phybs -rw -l 1024 /dev/ada2
   count    size  offset    step        msec     tps    kBps

  131072    1024       0    4096      205871     636     636
  131072    1024     512    4096      219599     596     596

   65536    2048       0    8192      174184     376     752
   65536    2048     512    8192      161844     404     809
   65536    2048    1024    8192      176060     372     744

   32768    4096       0   16384      144485     226     907
   32768    4096     512   16384      157527     208     832
   32768    4096    1024   16384      158052     207     829
   32768    4096    2048   16384      143603     228     912

   16384    8192       0   32768      126661     129    1034
   16384    8192     512   32768      133836     122     979
   16384    8192    1024   32768      125020     131    1048
   16384    8192    2048   32768      118295     138    1108
   16384    8192    4096   32768      114937     142    1140

Now, if only I knew what those meant….

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

  7 Responses to “Aligning disk partitions for better throughput”

  1. See this post for an explanation of phybs’s output.

    Quick primer: look at the second, third and last columns on each line. The second is the block size, the third is the offset and the last is the throughput. With the Seagate, you can clearly see that it performs best when both the block size and offset are multiples of 4096. The WD drive, on the other hand, doesn’t seem to prefer any particular block size or alignment, which indicates that unlike the Seagate, it is not a 4k drive.

    (you got the wrong product sheet for the Seagate; the right one clearly says 4096 bytes)

    However, both are dog slow—nowhere near what I’d expect from modern SATA drives. With 8192-byte writes, you should be getting around 20 to 30 MBps, and you’re only getting around 1 or 2 MBps. Can you try a sequential test?

  2. I wonder why both drives are so slow. I will try a sequential write. Are you expecting something like a ‘dd if=/dev/zero’?

  3. [dan@floater:~] $ sudo dd if=/dev/zero of=/dev/ada1 count=100000
    100000+0 records in
    100000+0 records out
    51200000 bytes transferred in 7.033895 secs (7279040 bytes/sec)

    [dan@floater:~] $ sudo dd if=/dev/zero of=/dev/ada1 count=600000
    600000+0 records in
    600000+0 records out
    307200000 bytes transferred in 42.317677 secs (7259378 bytes/sec)

    $ sudo dd if=/dev/zero of=/dev/ada1 count=1600000
    1600000+0 records in
    1600000+0 records out
    819200000 bytes transferred in 112.384917 secs (7289234 bytes/sec)

    Still, that’s only 6.9 MB / s

    Terrible. Why so terrible?

    Let’s try the other drive:

    $ sudo dd if=/dev/zero of=/dev/ada1 count=1600000
    1600000+0 records in
    1600000+0 records out
    819200000 bytes transferred in 112.384917 secs (7289234 bytes/sec)

    $ sudo dd if=/dev/zero of=/dev/ada2 count=1600000000
    1600000+0 records in
    1600000+0 records out
    819200000 bytes transferred in 135.923697 secs (6026911 bytes/sec)

  4. About that data sheet, it is interesting that when I go to your link, then click on support, I get taken to my link.

    But now I see the ‘Barracuda Data Sheet (455 KB)‘ link at the top of the page.

    I have updated my post with the real link. Thank you.

  5. Success. Try a bigger block size:

    $ sudo dd if=/dev/zero of=/dev/ada1 count=1600000 bs=32k
    Password:
    There’s a lot of it about, you know.
    Password:
    1600000+0 records in
    1600000+0 records out
    52428800000 bytes transferred in 365.299993 secs (143522587 bytes/sec)

  6. The other HDD is:

    $ sudo dd if=/dev/zero of=/dev/ada2 count=1600000 bs=32k
    1600000+0 records in
    1600000+0 records out
    52428800000 bytes transferred in 435.509907 secs (120384862 bytes/sec)

    That’s 114.807951 MB / s

    And the first one is 136.873805 MB / s

    I think everything is in order.

  7. I may buy a SATA 3 card.