67 lines
1.9 KiB
Diff
67 lines
1.9 KiB
Diff
From 1a38ea3b96dbe8fd2f2fca8ee9a501ef1423027f Mon Sep 17 00:00:00 2001
|
|
From: Guillaume Abrioux <gabrioux@redhat.com>
|
|
Date: Mon, 20 Jun 2022 13:43:43 +0200
|
|
Subject: [PATCH] ceph-volume: decrease number of `pvs` calls in `lvm list`
|
|
|
|
current implementation of `List.create_report()` implies a lot of calls
|
|
to `pvs` process. This could be avoided.
|
|
|
|
current implementation:
|
|
```
|
|
>>> import timeit
|
|
>>> from ceph_volume.devices.lvm.listing import List
|
|
>>> timeit.timeit(List([]).main, number=1000)
|
|
|
|
...
|
|
|
|
93.03700458299136
|
|
```
|
|
|
|
new implementation:
|
|
|
|
```
|
|
>>> import timeit
|
|
>>> from ceph_volume.devices.lvm.listing import List
|
|
>>> timeit.timeit(List([]).main, number=1000)
|
|
|
|
...
|
|
|
|
62.16391600697534
|
|
```
|
|
|
|
In this example, it improves performance by ~30%
|
|
|
|
Fixes: https://tracker.ceph.com/issues/56127
|
|
|
|
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
|
|
---
|
|
src/ceph-volume/ceph_volume/devices/lvm/listing.py | 5 +++--
|
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/ceph-volume/ceph_volume/devices/lvm/listing.py b/src/ceph-volume/ceph_volume/devices/lvm/listing.py
|
|
index 44d5063ce37..c16afdaa767 100644
|
|
--- a/src/ceph-volume/ceph_volume/devices/lvm/listing.py
|
|
+++ b/src/ceph-volume/ceph_volume/devices/lvm/listing.py
|
|
@@ -101,6 +101,8 @@ class List(object):
|
|
|
|
report = {}
|
|
|
|
+ pvs = api.get_pvs()
|
|
+
|
|
for lv in lvs:
|
|
if not api.is_ceph_device(lv):
|
|
continue
|
|
@@ -109,8 +111,7 @@ class List(object):
|
|
report.setdefault(osd_id, [])
|
|
lv_report = lv.as_dict()
|
|
|
|
- pvs = api.get_pvs(filters={'lv_uuid': lv.lv_uuid})
|
|
- lv_report['devices'] = [pv.name for pv in pvs] if pvs else []
|
|
+ lv_report['devices'] = [pv.name for pv in pvs if pv.lv_uuid == lv.lv_uuid] if pvs else []
|
|
report[osd_id].append(lv_report)
|
|
|
|
phys_devs = self.create_report_non_lv_device(lv)
|
|
--
|
|
2.33.0
|
|
|