]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
PGPool::update: avoid expensive union_of 17239/head
authorZac Medico <zmedico@gmail.com>
Thu, 24 Aug 2017 16:40:45 +0000 (09:40 -0700)
committerZac Medico <zmedico@gmail.com>
Thu, 24 Aug 2017 16:47:23 +0000 (09:47 -0700)
Achieve the same result using a swap (constant complexity),
and an assignment (linear complexity).

Signed-off-by: Zac Medico <zmedico@gmail.com>
src/osd/PG.cc

index 3f51b1eb2631b7aa7f947573eeba75a45a6a031c..3e671de9b092f52a55901d1742b9752f2899d43e 100644 (file)
@@ -241,8 +241,9 @@ void PGPool::update(OSDMapRef map)
     interval_set<snapid_t> intersection;
     intersection.intersection_of(newly_removed_snaps, cached_removed_snaps);
     if (intersection == cached_removed_snaps) {
-        newly_removed_snaps.subtract(cached_removed_snaps);
-        cached_removed_snaps.union_of(newly_removed_snaps);
+        cached_removed_snaps.swap(newly_removed_snaps);
+        newly_removed_snaps = cached_removed_snaps;
+        newly_removed_snaps.subtract(intersection);
     } else {
         lgeneric_subdout(cct, osd, 0) << __func__
           << " cached_removed_snaps shrank from " << cached_removed_snaps