Skip to content

Replace zfs-related subprocess calls by library calls #99

@Defenso-QTH

Description

@Defenso-QTH

This is a sub-item of #95.

In a profiling iocage list run I made of 0.795 seconds, 0.204 seconds were spent in zfs.py's run function, which is just a subprocess wrapper to call zfs(8) or zpool(8):

def run(command, **kwargs):
kwargs.setdefault('stdout', subprocess.PIPE)
kwargs.setdefault('stderr', subprocess.PIPE)
kwargs.setdefault('encoding', 'utf8')
check = kwargs.pop('check', True)
proc = subprocess.Popen(command, **kwargs)
stdout, stderr = proc.communicate()
cp = subprocess.CompletedProcess(
command, proc.returncode, stdout=stdout, stderr=stderr
)
if check:
try:
cp.check_returncode()
except subprocess.CalledProcessError:
raise ZFSException(cp.returncode, cp.stderr)
return cp

We could reduce this time by using libzfs, avoiding the process creation and communication overhead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions