From 1084428e45b3017a88bd3e8d3837a54e5783e935 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Wed, 23 Aug 2017 08:56:36 +0200 Subject: [PATCH 188/325] share/dtrace: Import zfs-txg-sync-info 2017-08-23-ed990899 Obtained from: ElectroBSD --- share/dtrace/Makefile | 3 +- share/dtrace/zfs-txg-sync-info | 58 ++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100755 share/dtrace/zfs-txg-sync-info diff --git a/share/dtrace/Makefile b/share/dtrace/Makefile index 66d0639ba365..218da556452f 100644 --- a/share/dtrace/Makefile +++ b/share/dtrace/Makefile @@ -23,7 +23,8 @@ SCRIPTS= blocking \ tcpstate \ tcptrack \ udptrack \ - zfsdbg-msg + zfsdbg-msg \ + zfs-txg-sync-info SCRIPTSDIR= ${SHAREDIR}/dtrace diff --git a/share/dtrace/zfs-txg-sync-info b/share/dtrace/zfs-txg-sync-info new file mode 100755 index 000000000000..00f5614cac2c --- /dev/null +++ b/share/dtrace/zfs-txg-sync-info @@ -0,0 +1,58 @@ +#!/usr/sbin/dtrace -s +/*************************************************************************** + * zfs-txg-sync-info.d + * + * Shows the txg sync time and the amount of dirty data that got synced. + * By default all pools are monitored. If a pool name is specified as + * first argument, only that pool is monitored. + * + * Inspired by: + * http://dtrace.org/blogs/ahl/2014/08/31/openzfs-tuning/ + * + * Copyright (c) 2017 Fabian Keil + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************/ + +#pragma D option quiet +#pragma D option defaultargs + +BEGIN +{ + pool_to_watch = $$1; +} + +txg-syncing +/pool_to_watch == NULL || pool_to_watch == ((dsl_pool_t *)arg0)->dp_spa->spa_name/ +{ + this->pool_name = stringof(((dsl_pool_t *)arg0)->dp_spa->spa_name); + sync_start[this->pool_name] = timestamp; + dp_dirty_total[this->pool_name] = ((dsl_pool_t *)arg0)->dp_dirty_total; + dp_dirty_percentage[this->pool_name] = dp_dirty_total[this->pool_name] / (`zfs_dirty_data_max / 100); +} + +txg-synced +/this->pool_name != NULL/ +{ + this->sync_time = timestamp - sync_start[this->pool_name]; + + printf("%Y: %s txg written in %d.%02d seconds. %3d.%02d MB were dirty (%2d%% of %d MB)\n", + walltimestamp, + this->pool_name, + this->sync_time / 1000000000, + this->sync_time / 10000000 % 100, + dp_dirty_total[this->pool_name] / 1024 / 1024, + dp_dirty_total[this->pool_name] / 1024 % 100, + dp_dirty_percentage[this->pool_name], + `zfs_dirty_data_max / 1024 / 1024); +} -- 2.32.0