get_zfs_dataset() takes an unreasonable amount of time
get_zfs_dataset() currently takes an unreasonable amount of time in the
process of sharing filesystems. It does multiple lookups of zfs
properties per filesystem on the machine, per filesystem that needs to
be shared (yes, quadratic in most cases).
The naive solution implemented in this change, is to make an optimistic
assumption that the mountpoint for a zfs filesystem is within a few
leading slashes of its name. So we cut off those leading slashes and
then check to see if such a filesystem exists. Only if the filesystem
has a custom mountpoint does this not work, so we turn a quadratic
operation into a constant time one (most of the time).
To verify the improvement, 10,000 zfs filesystems were created on a VM,
and the following command was used to share them all:
- sharemgr start zfs
Without this change, this operation took about 6.5 minutes; and with
this change, it took about 6.8 seconds.
Updated by Electric Monk about 4 years ago
- Status changed from New to Closed
- % Done changed from 0 to 100
commit 95e79c0b22e3ef2a1ac6412a4ab12cd99922fc12 Author: Daniel Hoffman <firstname.lastname@example.org> Date: 2017-01-18T22:45:59.000Z 7741 get_zfs_dataset() takes an unreasonable amount of time Reviewed by: Steve Gonczi <email@example.com> Reviewed by: George Wilson <firstname.lastname@example.org> Reviewed by: Matthew Ahrens <email@example.com> Approved by: Dan McDonald <firstname.lastname@example.org>