Skip to content

Commit

Permalink
PGPool::update: avoid expensive union_of
Browse files Browse the repository at this point in the history
Achieve the same result using a swap (constant complexity),
and an assignment (linear complexity).

Signed-off-by: Zac Medico <zmedico@gmail.com>
  • Loading branch information
zmedico committed Aug 24, 2017
1 parent 457c145 commit bf20b66
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/osd/PG.cc
Expand Up @@ -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
Expand Down

0 comments on commit bf20b66

Please sign in to comment.