-
Notifications
You must be signed in to change notification settings - Fork 15
Replace zfs-related subprocess calls by library calls #99
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
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):
Lines 8 to 23 in 6518661
| 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request