Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osd_types: optimized version of pg_pool_t::build_removed_snaps #17493

Closed
wants to merge 2 commits into from

Conversation

branch-predictor
Copy link
Contributor

Previous version iterated over entire range 1..get_snap_seq, and each time over entire snaps map (which is lgsnaps.size, making it MlgN), adding each missing snap by one (up to M*lgN). Reduce that considerably by iterating only over existing snaps and adding missing ones as ranges instead of relying on interval_set.insert(el) to coalesce them on-fly.

Signed-off-by: Piotr Dałek piotr.dalek@corp.ovh.com

@joscollin
Copy link
Member

Jenkins retest this please

@joscollin joscollin added the core label Sep 6, 2017
@branch-predictor
Copy link
Contributor Author

@joscollin can you add a performance tag too? This reduces cpu usage spikes on OSDMap updates when there's a lot of snapshots.

Previous version interated over entire range 1..get_snap_seq, and
each time over entire snaps map (which is lg*snaps.size, making it
M*lgN), adding each missing snap by one (up to M*lgN). Reduce that
considerably by iterating only over existing snaps and adding
missing ones as ranges instead of relying on
interval_set.insert(el, 1) to coalesce them on-fly.

Signed-off-by: Piotr Dałek <piotr.dalek@corp.ovh.com>
This introduces new method (build_removed_snaps_and_check_intersect)
which checks whether cached removed snaps interval set intersects
newly build removed snaps interval set. This lets us get rid of
creation of intermediate interval set, which is expensive in terms
of both CPU and memory when there's a lot of snaps.

Signed-off-by: Piotr Dałek <piotr.dalek@corp.ovh.com>
// this iterates linearly over snaps map, building deleted snap intervals in rs.
// it compares that with cached removed snaps (cached) and returns false if any of
// interval elements in cached doesn't exists in newly removed snaps (rs).
bool pg_pool_t::build_removed_snaps_and_check_intersect(interval_set<snapid_t>& rs,
Copy link
Contributor

@zmedico zmedico Sep 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the code in this method is only valid when is_pool_snaps_mode() returns true, so while it may be valid if you're using pool snaps, it doesn't seem valid if you're using self managed snaps.

Copy link
Contributor

@zmedico zmedico Sep 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since cached is not modified in this method, it can be passed as a const reference.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this whole method is equivalent to the following:

build_removed_snaps(rs);
return cached.subset_of(rs);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've distilled your patch into the following:

#17820

Copy link
Contributor

@zmedico zmedico Sep 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order for subset_of to be viable, it would need to dynamically choose between sequential search and lower_bound methods, like the intersect_of implementation since #17088.

@gregsfortytwo
Copy link
Member

As @zmedico suggests, this only works if using pool snapshots — which I expect to be almost nobody.

The optimizations for pool snapshots in build_removed_snaps looked right to me, so we can merge them in separately. But I’m closing the PR for the rest of it. :)

@branch-predictor branch-predictor deleted the bp-optimized-brs branch May 27, 2019 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants