From bf20b661cb6a6a33d9e93fb44ad1470f9f8245d2 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 24 Aug 2017 09:40:45 -0700 Subject: [PATCH] PGPool::update: avoid expensive union_of Achieve the same result using a swap (constant complexity), and an assignment (linear complexity). Signed-off-by: Zac Medico --- src/osd/PG.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 3f51b1eb2631b..3e671de9b092f 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -241,8 +241,9 @@ void PGPool::update(OSDMapRef map) interval_set 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 -- 2.39.5