Hi,
I recently bought an OCZ Vertex 2 90GB SSD. I will be using it as a system boot drive and plan to partition it with MBR style partitions. I decided to do some experimenting with partition boundaries before I put the drive to use. I'm going to dive right into the benchmarks I've done first, then explain my partitioning method afterwards.
The benchmarks are just sequential writes with dd. I know this is simplistic, but it does demonstrate the point of this post, and I'm happy to take suggestions on further benchmarks before I put this SSD to use.
Preparation
First I set up a tmpfs(5) file system and wrote a 512 MiB file filled with random data. I'll be using this file to write to the SSD.
Initial partitions
I create the first partition at the usual 63 sectors offset from the start of the disk (track 1) which is unaligned with the SSD erase block. The second partition is set to start at sector 21030912 (10767826944 bytes) which is aligned with the SSD erase block.
BSD labels and UFS file systems
I create the UFS file systems by calling newfs(8) with the -E parameter so that the SSD is erased using TRIM hardware commands.
Mount points
First tests
The unaligned partition performs about 25% slower at a sequential write than the aligned partition. It also loses speed with subsequent writes which doesn't happen on the aligned partition.
Refresh file systems
I wanted to see if TRIM could restore the speed of the first partition.
Looks like a TRIM on the unaligned partition brought it back up to speed...
Align unaligned partition
So let's destroy the first partition and adjust its starting point so that it is aligned with the SSD erase block boundaries. I recreate it to start at sector 129024 (66060288 bytes) which is aligned.
Wallah.
So it seems pretty clear from these basic tests that correct partition alignment improves SSD throughput. Anyone want me to do more extensive tests?
I recently bought an OCZ Vertex 2 90GB SSD. I will be using it as a system boot drive and plan to partition it with MBR style partitions. I decided to do some experimenting with partition boundaries before I put the drive to use. I'm going to dive right into the benchmarks I've done first, then explain my partitioning method afterwards.
The benchmarks are just sequential writes with dd. I know this is simplistic, but it does demonstrate the point of this post, and I'm happy to take suggestions on further benchmarks before I put this SSD to use.
Preparation
First I set up a tmpfs(5) file system and wrote a 512 MiB file filled with random data. I'll be using this file to write to the SSD.
# mkdir /tmp/tst
# kldload tmpfs
# mount -t tmpfs tmpfs /tmp/tst
# dd if=/dev/urandom of=/tmp/tst/rand bs=1m count=512
Initial partitions
I create the first partition at the usual 63 sectors offset from the start of the disk (track 1) which is unaligned with the SSD erase block. The second partition is set to start at sector 21030912 (10767826944 bytes) which is aligned with the SSD erase block.
# gpart create -s MBR ada0
# gpart add -s 10g -t freebsd ada0
# gpart add -b 21030912 -s 10g -t freebsd ada0
Code:
# gpart show ada0
=> 63 175836465 ada0 MBR (84G)
63 20971503 1 freebsd (10G)
20971566 59346 - free - (29M)
21030912 20971503 2 freebsd (10G)
42002415 133834113 - free - (64G)
BSD labels and UFS file systems
I create the UFS file systems by calling newfs(8) with the -E parameter so that the SSD is erased using TRIM hardware commands.
# gpart create -s BSD ada0s1
# gpart create -s BSD ada0s2
# gpart add -s 1g -t freebsd-ufs ada0s1
# gpart add -s 1g -t freebsd-ufs ada0s2
Code:
# gpart show ada0s1
=> 0 20971503 ada0s1 BSD (10G)
0 2097152 1 freebsd-ufs (1.0G)
2097152 18874351 - free - (9.0G)
# gpart show ada0s2
=> 0 20971503 ada0s2 BSD (10G)
0 2097152 1 freebsd-ufs (1.0G)
2097152 18874351 - free - (9.0G)
# newfs -E ada0s1a
/dev/ada0s1a: 1024.0MB (2097152 sectors) block size 16384, fragment size 2048
using 6 cylinder groups of 183.72MB, 11758 blks, 23552 inodes.
Erasing sectors [128...2097151]
super-block backups (for fsck -b #) at:
160, 376416, 752672, 1128928, 1505184, 1881440
# newfs -E ada0s2a
/dev/ada0s2a: 1024.0MB (2097152 sectors) block size 16384, fragment size 2048
using 6 cylinder groups of 183.72MB, 11758 blks, 23552 inodes.
Erasing sectors [128...2097151]
super-block backups (for fsck -b #) at:
160, 376416, 752672, 1128928, 1505184, 1881440
Mount points
# mount -t ufs /dev/ada0s1a /mnt/1
# mount -t ufs /dev/ada0s2a /mnt/2
First tests
Code:
# dd if=/tmp/tst/rand of=/mnt/1/rand bs=1m
512+0 records in
512+0 records out
536870912 bytes transferred in 5.721152 secs (93839651 bytes/sec)
# dd if=/tmp/tst/rand of=/mnt/2/rand bs=1m
512+0 records in
512+0 records out
536870912 bytes transferred in 4.318652 secs (124314467 bytes/sec)
# dd if=/tmp/tst/rand of=/mnt/1/rand bs=1m
512+0 records in
512+0 records out
536870912 bytes transferred in 6.489263 secs (82732185 bytes/sec)
# dd if=/tmp/tst/rand of=/mnt/2/rand bs=1m
512+0 records in
512+0 records out
536870912 bytes transferred in 4.088808 secs (131302547 bytes/sec)
# dd if=/tmp/tst/rand of=/mnt/1/rand bs=1m
512+0 records in
512+0 records out
536870912 bytes transferred in 6.750464 secs (79530965 bytes/sec)
# dd if=/tmp/tst/rand of=/mnt/2/rand bs=1m
512+0 records in
512+0 records out
536870912 bytes transferred in 4.091864 secs (131204490 bytes/sec)
The unaligned partition performs about 25% slower at a sequential write than the aligned partition. It also loses speed with subsequent writes which doesn't happen on the aligned partition.
Refresh file systems
I wanted to see if TRIM could restore the speed of the first partition.
# umount /mnt/1 /mnt/2
# newfs -E ada0s1a
# newfs -E ada0s2a
# mount -t ufs /dev/ada0s1a /mnt/1
# mount -t ufs /dev/ada0s2a /mnt/2
Code:
# dd if=/tmp/tst/rand of=/mnt/1/rand bs=1m
512+0 records in
512+0 records out
536870912 bytes transferred in 5.906114 secs (90900874 bytes/sec)
# dd if=/tmp/tst/rand of=/mnt/2/rand bs=1m
512+0 records in
512+0 records out
536870912 bytes transferred in 4.088698 secs (131306084 bytes/sec)
Looks like a TRIM on the unaligned partition brought it back up to speed...
Align unaligned partition
So let's destroy the first partition and adjust its starting point so that it is aligned with the SSD erase block boundaries. I recreate it to start at sector 129024 (66060288 bytes) which is aligned.
# gpart delete -i 1 ada0s1
# gpart destroy ada0s1
# gpart delete -i 1 ada0
# gpart add -t freebsd -b 129024 -s 20842479 -i 1 ada0
Code:
# gpart show ada0
=> 63 175836465 ada0 MBR (84G)
63 128961 - free - (63M)
129024 20842479 1 freebsd (9.9G)
20971503 59409 - free - (29M)
21030912 20971503 2 freebsd (10G)
42002415 133834113 - free - (64G)
# gpart create -s BSD ada0s1
# gpart add -t freebsd-ufs -s 1g ada0s1
# newfs -E ada0s1a
# mount -t ufs /dev/ada0s1a /mnt/1
Code:
# dd if=/tmp/tst/rand of=/mnt/1/rand bs=1m
512+0 records in
512+0 records out
536870912 bytes transferred in 4.075008 secs (131747207 bytes/sec)
# dd if=/tmp/tst/rand of=/mnt/1/rand bs=1m
512+0 records in
512+0 records out
536870912 bytes transferred in 4.077147 secs (131678085 bytes/sec)
# dd if=/tmp/tst/rand of=/mnt/1/rand bs=1m
512+0 records in
512+0 records out
536870912 bytes transferred in 4.073861 secs (131784294 bytes/sec)
Wallah.
So it seems pretty clear from these basic tests that correct partition alignment improves SSD throughput. Anyone want me to do more extensive tests?