Repository navigation
OSDMap::calc_pg_maps: fix balancing for some (important) corner cases - #65191
Conversation
|
This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days. |
There was a problem hiding this comment.
LGTM - both cases are important for relatively complex balancing scenarios.
@ljflores - if it looks OK to you, please merge.
|
This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days. |
|
This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution! |
|
This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days. |
|
This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution! |
|
jenkins test docs |
aa87ed4 to
e473526
Compare
In some cases the balancer can stall out, unable to find any changes that will help overfull or underfull OSDs get closer to their target num PGs. Here's an example from the wild. These changes are not accepted because the overall stddev does not appear to be decreasing: will try dropping existing remapping pair 264 -> 137 which remapped 24.f9d into overfull osd.137 existing pg_upmap_items [766,799,264,137] remapped 24.f9d into overfull osd.137, new_pg_upmap_items now [766,799] stddev 138085.453125 -> 138085.453125 will try dropping existing remapping pair 496 -> 637 which remapped 24.5ca out from underfull osd.496 existing pg_upmap_items [729,790,496,637] remapped 24.5ca out from underfull osd.496, new_pg_upmap_items now [729,790] stddev 138085.453125 -> 138085.453125 Those changes will now be accepted, which is good because those OSDs will improve, even though the sum of squared deviations does not. Note that a change scoring exactly equal still moves data, so this trades some churn for the ability to escape a plateau. The two following patches make the score both more meaningful and precise enough to tell many of these cases apart on their own merits. Signed-off-by: Dan van der Ster <[email protected]>
Currently we score how balanced we are using a sum of the absolute deviations, treating small and large OSDs equally. This strongly under values relatively small PGs, which we really need to be accurately balancing with priority to avoid them getting overfull. Consider this scenario: osd.0 weight 100.0 pgs 100 target 100 -> deviation 0 osd.1 weight 1.0 pgs 2 target 1 -> deviation 1 The tiny OSD osd.1 is 2x overfull -- we should prioritize moving one of its PGs to osd.0, which would only go 1% overfull. The new values would become: osd.0 weight 100.0 pgs 101 target 100 -> deviation 1 osd.1 weight 1.0 pgs 1 target 1 -> deviation 0 With the "stddev" calculation, we have these before/after scores: stddev = 0*0 + 1*1 = 1 new_stddev = 1*1 + 0*0 = 1 (Until recently, that change would be rejected because it does not decrease the stddev). To improve things, we calculate a bal_score which incorporates the relative deviation and OSD weights. Here's the new scores for the example change above: bal_score = (100/100 - 1)^2 * 100 + (2/1 - 1)^2 * 1 = 1 new_bal_score = (101/100 - 1)^2 * 100 + (1/1 - 1)^2 * 1 = 0.01 With this new approach the change is highly favourable, as it should be. Note that this changes only how an already proposed change is scored. Deciding whether to run at all, which OSDs are overfull or underfull, and which remap to propose are all still done in absolute PG deviations against max_deviation, so a small OSD like osd.1 above only gets this attention once some OSD in the tree is more than max_deviation PGs away from its target. Signed-off-by: Dan van der Ster <[email protected]>
bal_score is a sum taken over every OSD in the crush tree, while a proposed change modifies just two of its terms. In float the delta can land below the ULP of the total, so two genuinely different mappings compare equal and we cannot tell an improvement from a regression. That is what the stalled balancer in "accept more proposed changes" was really hitting. try_drop_remap_overfull only proposes a drop when osd_deviation[um_from] + 1 < osd_deviation[osd], and for a sum of squared deviations that gives delta = 2 * (dev_from - dev_to + 1) < 0 so the change was strictly improving; it printed as unchanged only because float at a magnitude of 138085 has a ULP of ~0.016. The weighted score reduces the magnitude of the sum considerably, but it does not remove the failure mode. Simulating a 3000 OSD tree with ~100 PGs per OSD and a drop which satisfies the guard above: float 595.903381 -> 595.903381 delta +0 tie double 595.902895 -> 595.902893 delta -1.98364e-06 accepted While here: - Derive the relative deviation from the absolute one rather than computing pgs / target - 1, which loses precision to cancellation when pgs is close to target. - Log the delta next to the two totals. The totals are printed with the stream's default 6 significant digits, which is exactly enough to hide the improvements of interest here. - Assert target > 0 in calc_deviations, which now divides by it. Both callers already assert this before their own use. - Rename the parameter in the header declaration to match the definition. Signed-off-by: Dan van der Ster <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
e473526 to
6aecf7b
Compare
|
This PR has been added to wip-bharath3-testing-20260824.233415-main. |
This PR fixes upmap balancing for two existing balancer problems: stall out due to stddev not decreasing, and undervaluing the deviation of small OSDs.
https://tracker.ceph.com/issues/78314
Accept changes that don't decrease stddev
In some cases the balancer can stall out, unable to find any
changes that will help overfull or underfull OSDs get closer
to their target num PGs.
Here's an example from the wild. These changes are not
accepted because the overall stddev is not decreasing:
Those changes will now be accepted, which is good because those
OSDs will improve, even though the sum of squared deviations does
not.
Also fix some debug outputs.
Improved OSDMap balancing "score"
Currently we score how balanced we are using a sum of the absolute
deviations, treating small and large OSDs equally. This strongly
under values relatively small PGs, which we really need to be
accurately balancing with priority to avoid them getting overfull.
Consider this scenario:
osd.0 weight 100.0 pgs 100 target 100 -> deviation 0osd.1 weight 1.0 pgs 2 target 1 -> deviation 1The tiny OSD osd.1 is 2x overfull -- we should prioritize moving
one of its PGs to osd.0, which would only go 1% overfull. The
new values would become:
osd.0 weight 100.0 pgs 101 target 100 -> deviation 1osd.1 weight 1.0 pgs 1 target 1 -> deviation 0With the "stddev" calculation, we have these before/after scores:
stddev = 0*0 + 1*1 = 1new_stddev = 1*1 + 0*0 = 1(Until recently, that change would be rejected because it does not
decrease the stddev).
To improve things, we calculate a bal_score which incorporates the
relative deviation and OSD weights.
Here's the new scores for the example change above:
bal_score = (100/100 - 1)^2 * 100 + (2/1 - 1)^2 * 1 = 2new_bal_score = (101/100 - 1)^2 * 100 + (1/1 - 1)^2 * 1 = 0.01With this new approach the change is highly favourable, as it
should be.
Checklist