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

Signed-off-by: Zac Medico <zmedico@gmail.com>
(cherry picked from commit bf20b661cb6a6a33d9e93fb44ad1470f9f8245d2)

src/osd/PG.cc

index 04f2d92828d957a4fb1d931f5266ab7de9571926..1e32d202dae470701816e8ae016ce5cdeb47ba11 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