ceph-volume: avoid unnecessary subprocess calls#46766
Merged
Conversation
8d0e337 to
9c049f0
Compare
7a45989 to
c5dae72
Compare
Contributor
Author
|
jenkins test ceph-volume tox |
c5dae72 to
b849773
Compare
Contributor
Author
|
jenkins test api |
9a8f54b to
f457913
Compare
Contributor
Author
|
jenkins test ceph-volume tox |
f457913 to
d720fad
Compare
This name is misleading, let's rename it for something clearer. Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
d720fad to
15c9265
Compare
Contributor
Author
|
jenkins test ceph-volume tox |
15c9265 to
cb79153
Compare
Contributor
Author
|
jenkins test ceph-volume tox |
These calls are slowing down `ceph-volume inventory`.
Especially because of the class `ceph_volume.util.device.Devices`.
It calls the class `ceph_volume.util.device.Device` for each device found
on the host which calls many times the binaries `lsblk`, `pvs`, `vgs`, `lvs` itself.
We can make only one call in `Devices()` to gather all details and use them during the whole runtime
current implementation:
```
1 0.000 0.000 0.892 0.892 device.py:35(__init__) (class Devices)
8 0.001 0.000 0.853 0.107 device.py:151(_parse)
56 0.002 0.000 0.882 0.016 process.py:154(call)
8 0.001 0.000 0.245 0.031 lvm.py:1099(get_lvs)
8 0.000 0.000 0.026 0.003 disk.py:231(lsblk)
8 0.000 0.000 0.435 0.054 device.py:278(_set_lvm_membership)
1 0.000 0.000 0.885 0.885 device.py:38(<listcomp>) (multiple calls to Device() class)
8/5 0.000 0.000 0.885 0.177 device.py:92(__init__) (class Device)
>>> timeit.timeit('Inventory([]).main()', setup='from ceph_volume.inventory import Inventory', number=1)
Device Path Size rotates available Model name
/dev/sdb 200.00 GB True True QEMU HARDDISK
/dev/sda 200.00 GB True False QEMU HARDDISK
/dev/sdc 200.00 GB True False QEMU HARDDISK
/dev/sdd 200.00 GB True False QEMU HARDDISK
/dev/vda 11.00 GB True False
0.9309048530412838
>>>
```
new approach:
```
1 0.000 0.000 0.253 0.253 device.py:35(__init__) (class Devices)
5 0.000 0.000 0.144 0.029 device.py:167(_parse)
21 0.001 0.000 0.246 0.012 process.py:154(call)
1 0.000 0.000 0.032 0.032 lvm.py:1110(get_lvs)
1 0.000 0.000 0.005 0.005 disk.py:236(lsblk_all)
5 0.000 0.000 0.062 0.012 device.py:309(_set_lvm_membership)
1 0.000 0.000 0.179 0.179 device.py:41(<listcomp>) (multiple calls to Device() class)
5 0.000 0.000 0.179 0.036 device.py:99(__init__) (class Device)
>>> timeit.timeit('Inventory([]).main()', setup='from ceph_volume.inventory import Inventory', number=1)
Device Path Size rotates available Model name
/dev/sdb 200.00 GB True True QEMU HARDDISK
/dev/sda 200.00 GB True False QEMU HARDDISK
/dev/sdc 200.00 GB True False QEMU HARDDISK
/dev/sdd 200.00 GB True False QEMU HARDDISK
/dev/vda 11.00 GB True False
0.2486933789914474
>>>
```
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
cb79153 to
bea9f4b
Compare
Contributor
Author
|
jenkins test ceph-volume tox |
Contributor
|
Looks good. I tested on a physical machine with a bunch of ssd/nvme drives Before [ceph: root@f12-h09-000-1029u /]# time ceph-volume inventory Device Path Size rotates available Model name /dev/sdb 894.25 GB False True INTEL SSDSC2KB96 /dev/sdc 894.25 GB False True INTEL SSDSC2KB96 /dev/sdd 894.25 GB False True INTEL SSDSC2KB96 /dev/sde 894.25 GB False True INTEL SSDSC2KB96 /dev/nvme0n1 894.25 GB False False SAMSUNG MZ1LW960HMJP-00003 /dev/nvme1n1 894.25 GB False False SAMSUNG MZQLB960HAJR-00007 /dev/nvme2n1 894.25 GB False False SAMSUNG MZQLB960HAJR-00007 /dev/nvme3n1 447.12 GB False False Linux /dev/nvme3n2 447.12 GB False False Linux /dev/nvme3n3 447.12 GB False False Linux /dev/nvme3n4 447.12 GB False False Linux /dev/nvme3n5 447.12 GB False False Linux /dev/nvme3n6 447.12 GB False False Linux /dev/sda 447.13 GB False False INTEL SSDSC2KB48 real 0m3.559s user 0m0.931s sys 0m0.957s After (ceph-volume-testing) [root@f12-h09-000-1029u inventory]# time ceph-volume inventory
Device Path Size rotates available Model name
/dev/sdb 894.25 GB False True INTEL SSDSC2KB96
/dev/sdc 894.25 GB False True INTEL SSDSC2KB96
/dev/sdd 894.25 GB False True INTEL SSDSC2KB96
/dev/sde 894.25 GB False True INTEL SSDSC2KB96
/dev/nvme0n1 894.25 GB False False SAMSUNG MZ1LW960HMJP-00003
/dev/nvme1n1 894.25 GB False False SAMSUNG MZQLB960HAJR-00007
/dev/nvme2n1 894.25 GB False False SAMSUNG MZQLB960HAJR-00007
/dev/nvme3n1 447.12 GB False False Linux
/dev/nvme3n2 447.12 GB False False Linux
/dev/nvme3n3 447.12 GB False False Linux
/dev/nvme3n4 447.12 GB False False Linux
/dev/nvme3n5 447.12 GB False False Linux
/dev/nvme3n6 447.12 GB False False Linux
/dev/sda 447.13 GB False False INTEL SSDSC2KB48
real 0m1.086s
user 0m0.424s
sys 0m0.295s
(ceph-volume-testing) [root@f12-h09-000-1029u inventory]# deactivate
|
Contributor
|
4 Failed tests from and 1 dead test from I believe these are all infra issues and I did see these same failures in another run with different PRs (and notably, not on the same tests) in Quite confident the failures are unrelated to PRs in the run, so I think we're good here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These calls are slowing down
ceph-volume inventory.Especially because of the class
ceph_volume.util.device.Devices.It calls the class
ceph_volume.util.device.Devicefor each device foundon the host which calls many times the binaries
lsblk,pvs,vgs,lvsitself.We can make only one call in
Devices()to gather all details and use them during the whole runtimecurrent implementation:
new approach:
Signed-off-by: Guillaume Abrioux gabrioux@redhat.com