-
-
Save baitisj/b689e1345c8bdd8d9f60 to your computer and use it in GitHub Desktop.
rw.d dtrace FreeBSD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma D option quiet | |
/* dtrace D script for helping to tune the OpenZFS write throttle */ | |
/* Original script from: */ | |
/* http://dtrace.org/blogs/ahl/2014/08/31/openzfs-tuning/ */ | |
/* Example invocation that collects statistics over 1 minute: */ | |
/* dtrace -s rw.d -c 'sleep 60' */ | |
BEGIN | |
{ | |
bio_cmd[1] = "Read"; | |
bio_cmd[2] = "Write"; | |
bio_cmd[4] = "Delete"; | |
bio_cmd[8] = "Getattr"; | |
bio_cmd[16] = "Flush"; | |
start = timestamp; | |
} | |
io:::start | |
/args[0] != NULL && args[1] != NULL/ | |
{ | |
/* Rather than relying on args[0]->bio_disk->d_geom->name, */ | |
/* FreeBSD assigns a unique device_number per device.*/ | |
/* See man devstat for more information */ | |
ts[args[1]->device_number, args[0]->bio_pblkno] = timestamp; | |
} | |
io:::done | |
/args[0] != NULL && args[1] != NULL && ts[args[1]->device_number, args[0]->bio_pblkno]/ | |
{ | |
this->delta = (timestamp - ts[args[1]->device_number, args[0]->bio_pblkno]) / 1000; | |
this->name = bio_cmd[args[0]->bio_cmd]; | |
@q[this->name] = quantize(this->delta); | |
@a[this->name] = avg(this->delta); | |
@v[this->name] = stddev(this->delta); | |
@i[this->name] = count(); | |
@b[this->name] = sum(args[0]->bio_bcount); | |
ts[args[1]->device_number, args[0]->bio_pblkno] = 0; | |
} | |
END | |
{ | |
printa(@q); | |
normalize(@i, (timestamp - start) / 1000000000); | |
normalize(@b, (timestamp - start) / 1000000000 * 1024); | |
printf("%-30s %11s %11s %11s %11s\n", "", "avg latency", "stddev", | |
"iops", "throughput"); | |
printa("%-30s %@9uus %@9uus %@9u/s %@8uk/s\n", @a, @v, @i, @b); | |
} | |
/* FreeBSD sysctl tuneables of interest: | |
vfs.zfs.vdev.trim_max_active: 64 | |
vfs.zfs.vdev.trim_min_active: 1 | |
vfs.zfs.vdev.scrub_max_active: 2 | |
vfs.zfs.vdev.scrub_min_active: 1 | |
vfs.zfs.vdev.async_write_max_active: 10 | |
vfs.zfs.vdev.async_write_min_active: 1 | |
vfs.zfs.vdev.async_read_max_active: 3 | |
vfs.zfs.vdev.async_read_min_active: 1 | |
vfs.zfs.vdev.sync_write_max_active: 10 | |
vfs.zfs.vdev.sync_write_min_active: 10 | |
vfs.zfs.vdev.sync_read_max_active: 10 | |
vfs.zfs.vdev.sync_read_min_active: 10 | |
vfs.zfs.vdev.max_active: 1000 | |
vfs.zfs.vdev.async_write_active_max_dirty_percent: 60 | |
vfs.zfs.vdev.async_write_active_min_dirty_percent: 30 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment