Skip to content

Instantly share code, notes, and snippets.

@evansus
Last active August 29, 2015 14:14
Show Gist options
  • Save evansus/2e77ac5a96d023bbe501 to your computer and use it in GitHub Desktop.
Save evansus/2e77ac5a96d023bbe501 to your computer and use it in GitHub Desktop.
zvol_io_histograms.d
#!/usr/sbin/dtrace -s
#pragma D option quiet
/*
* Sizes and times (in microseconds) of all zvol I/O functions:
* net_lundman_zfs_zvol_device::doAsyncReadWrite
* net_lundman_zfs_zvol_device::doUnmap
* net_lundman_zfs_zvol_device::doDiscard
* zvol_read_iokit
* zvol_write_iokit
* zvol_unmap
*
* (Note: The upstream functions zvol_read() and zvol_write()
* are not used by the IOKit implementation)
*/
dtrace:::BEGIN
{
printf("Tracing for 10 seconds... Hit Ctrl-C to end.\n");
}
tick-10000msec {
exit(0);
}
fbt::_ZN27net_lundman_zfs_zvol_device16doAsyncReadWriteEP18IOMemoryDescriptoryyP19IOStorageAttributesP19IOStorageCompletion:entry
{
self->rw_start = vtimestamp;
/* Get read/write byte count */
@rw_sizes = quantize(arg3);
}
fbt::_ZN27net_lundman_zfs_zvol_device16doAsyncReadWriteEP18IOMemoryDescriptoryyP19IOStorageAttributesP19IOStorageCompletion:return
/(self->rw_start)/
{
/* Get elapsed time */
@rw_times = quantize((vtimestamp - self->rw_start)/1000);
}
fbt::zvol_read_iokit:entry
{
self->read_start = vtimestamp;
/* Get read byte count */
@read_sizes = quantize(arg2);
}
fbt::zvol_read_iokit:return
/(self->read_start)/
{
/* Get elapsed time */
@read_times = quantize((vtimestamp - self->read_start)/1000);
}
fbt::zvol_write_iokit:entry
{
self->write_start = vtimestamp;
/* Get write byte count */
@write_sizes = quantize(arg2);
}
fbt::zvol_write_iokit:return
/(self->write_start)/
{
/* Get elapsed time */
@write_times = quantize((vtimestamp - self->write_start)/1000);
}
fbt::_ZN27net_lundman_zfs_zvol_device7doUnmapEP26IOBlockStorageDeviceExtentjj:entry
{
self->dounmap_start = vtimestamp;
/* Get doUnmap block count */
@dounmap_sizes = quantize(arg2);
}
fbt::_ZN27net_lundman_zfs_zvol_device7doUnmapEP26IOBlockStorageDeviceExtentjj:return
/(self->dounmap_start)/
{
/* Get elapsed time */
@dounmap_times = quantize((vtimestamp - self->dounmap_start)/1000);
}
fbt::_ZN27net_lundman_zfs_zvol_device9doDiscardEyy:entry
{
self->discard_start = vtimestamp;
/* Get discard block count */
@discard_sizes = quantize(arg2);
}
fbt::_ZN27net_lundman_zfs_zvol_device9doDiscardEyy:return
/(self->discard_start)/
{
/* Get elapsed time */
@discard_times = quantize((vtimestamp - self->discard_start)/1000);
}
fbt::zvol_unmap:entry
{
self->unmap_start = vtimestamp;
/* Get unmap block count */
@unmap_sizes = quantize(arg2);
}
fbt::zvol_unmap:return
/(self->unmap_start)/
{
/* Get elapsed time */
@unmap_times = quantize((vtimestamp - self->unmap_start)/1000);
}
dtrace:::END
{
printf("==============================================================\n");
printf("\n%s\n", "zvol::doAsyncReadWrite count");
printa("%@d\n", @rw_sizes);
printf("==============================================================\n");
printf("\n%s\n", "zvol_read_iokit size");
printa("%@d\n", @read_sizes);
printf("==============================================================\n");
printf("\n%s\n", "zvol_write_iokit size");
printa("%@d\n", @write_sizes);
printf("==============================================================\n");
printf("\n%s\n", "zvol::doUnmap count");
printa("%@d\n", @dounmap_sizes);
printf("==============================================================\n");
printf("\n%s\n", "zvol::doDiscard count");
printa("%@d\n", @discard_sizes);
printf("==============================================================\n");
printf("\n%s\n", "zvol_unmap size");
printa("%@d\n", @unmap_sizes);
printf("==============================================================\n");
printf("\n");
printf("==============================================================\n");
printf("\n%s\n", "zvol::doAsyncReadWrite time delta");
printa("%@d\n", @rw_times);
printf("==============================================================\n");
printf("\n%s\n", "zvol_read_iokit time delta");
printa("%@d\n", @read_times);
printf("==============================================================\n");
printf("\n%s\n", "zvol_write_iokit time delta");
printa("%@d\n", @write_times);
printf("==============================================================\n");
printf("\n%s\n", "zvol::doUnmap time delta");
printa("%@d\n", @dounmap_times);
printf("==============================================================\n");
printf("\n%s\n", "zvol::doDiscard time delta");
printa("%@d\n", @discard_times);
printf("==============================================================\n");
printf("\n%s\n", "zvol_unmap time delta");
printa("%@d\n", @unmap_times);
printf("==============================================================\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment