From ba0e1749ec1841bb8f9d704225e6df04787dc608 Mon Sep 17 00:00:00 2001 From: Joel Low Date: Mon, 29 May 2023 11:47:28 +0800 Subject: [PATCH] perf(zfs): optimise pool listing for pools with many datasets (#440) Restricting the `zfs list` command to depth 1 saves a lot of time for pools with many datasets/zvols. In my case, before: ``` $ time zfs list -s name -o name,guid,available -H -p >/dev/null real 0m3.853s user 0m0.171s sys 0m3.539s ``` After: ``` $ time zfs list -d 1 -s name -o name,guid,available -H -p >/dev/null real 0m0.027s user 0m0.002s sys 0m0.026s ``` Signed-off-by: Joel Low --- changelogs/unreleased/440-lowjoel | 1 + pkg/zfs/zfs_util.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/440-lowjoel diff --git a/changelogs/unreleased/440-lowjoel b/changelogs/unreleased/440-lowjoel new file mode 100644 index 0000000..dacd704 --- /dev/null +++ b/changelogs/unreleased/440-lowjoel @@ -0,0 +1 @@ +optimise pool listing for pools with many datasets diff --git a/pkg/zfs/zfs_util.go b/pkg/zfs/zfs_util.go index 2f156fa..4ae9a63 100644 --- a/pkg/zfs/zfs_util.go +++ b/pkg/zfs/zfs_util.go @@ -921,7 +921,7 @@ func CreateRestore(rstr *apis.ZFSRestore) error { // pools in the node. func ListZFSPool() ([]apis.Pool, error) { args := []string{ - ZFSListArg, "-s", "name", + ZFSListArg, "-d", "1", "-s", "name", "-o", "name,guid,available", "-H", "-p", }