# Measuring disk performance



## balanga (Oct 14, 2017)

How do I measure disk performance under FreeBSD, and how can I tell what SATA interface I have?


----------



## Minbari (Oct 14, 2017)

smartmontools, camcontrol.*https://www.freshports.org/sysutils/smartmontools/*


----------



## ralphbsz (Oct 14, 2017)

For SATA, `smartctl` will give you the rotation rate of the disk and the bandwidth of the interface:

```
# smartctl -a /dev/ada3
smartctl 6.5 2016-05-07 r4318 [FreeBSD 11.1-RELEASE-p1 i386] (local build)
...
Model Family:     HGST MegaScale 4000
Device Model:     HGST HMS5C4040BLE640
...
User Capacity:    4,000,787,030,016 bytes [4.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5700 rpm
Form Factor:      3.5 inches
...
SATA Version is:  SATA 3.0, 6.0 Gb/s (current: 3.0 Gb/s)
...
```
That gives you the most important "static" measurements of the disk: capacity, block size (a.k.a. sector size), RPM, and interface bandwidth.  For SCSI disks, you can use various sg_utils commands (like sg_readcap and sg_inq -p 0xb0) to get the same data.

The easiest way to get a pretty accurate idea of the actual performance of the disk: Use the model number to look up the specification of the drive at the vendor web site; that gives you head bandwidth (which varies across the platter, more outside, less inside), and the seek speed.

Actually measuring it yourself is remarkably difficult.  Sure, you can do `dd if=/dev/adaX of=/dev/null bs=1M` and commands like that, but that result has very little to do with real-world performance.  You can download benchmarks like FIO and Bonnie and run them, and they will give you numbers, but those numbers are only useful to compare the Bonnie results of disks to each other, and have only a weak correlation with the real world.  In a previous job, I used to do this for a living, and our group had hundreds of thousands of lines of self-written code for that purpose; my workload generator (which gives IOs to the disk) alone was about 30KLOC.  But even with all these tools, you are just measuring the performance of the raw disk (or the hardware interface to the disk).  What really matters is the performance of your application, and there other factors (such as caching, memory pressure, file system, metadata, perhaps network interfaces if the data comes over NFS or Samba) play a huge role.  As an example: the exact same hardware will have very different performance, depending on whether you use FAT+Netware versus GPFS as the file/cluster system.  In the end, the only valid benchmark is: run your application, and measure whether it's performance is sufficient or not.


----------



## Phishfry (Oct 14, 2017)

`iostat` and `diskinfo -t` also show disk usage numbers.


----------



## Deleted member 45312 (Oct 14, 2017)

I got this with zcav from benchmarks/bonnie++ and math/gnuplot.


----------

