Skip to content

mgr: leave read balance scores out of the osd_map getter - #73045

Merged
idryomov merged 1 commit into
ceph:mainfrom
anthonyeleven:wip-mgr-osd-map-no-read-balance
Nov 11, 2026
Merged

idryomov merged 1 commit into
ceph:mainfrom
anthonyeleven:wip-mgr-osd-map-no-read-balance

Conversation

@anthonyeleven

@anthonyeleven anthonyeleven commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes: https://tracker.ceph.com/issues/82063

OSDMap::dump computes a read balance score for every replicated pool, and each score maps every PG of the pool. The mgr's osd_map getter dumps the map under the GIL whenever a Python module asks for it, so every module stalls while the scores are computed.

On a Reef 18.2.8 cluster with 1,018 OSDs, 134 replicated pools and 10,108 pg_upmap_items entries, osdmaptool --dump json of the same map takes 2.55 s with Reef and 0.09 s with Quincy, which has no read balance score. The prometheus module reads osd_map twice per collection there, and the mgr stops dispatching messages for about 7 s each time. rbd_support reads it twice a minute.

No module needs the scores from osd_map:

  • The balancer, the only module that uses them, gets them from get_osdmap().dump(), which still includes them.
  • ceph osd dump and ceph osd pool ls detail are served by the mons and are unchanged.
  • The dashboard passes every pool field through /api/pool, including read_balance. Neither its UI nor its OpenAPI spec uses it, so the field just stops appearing there.

This adds a with_read_balance argument to OSDMap::dump, true by default, and to dump_pool. Only the osd_map getter passes false, so every other dump keeps the scores, including the mons' osd dump and report, osdmaptool --dump, ceph-dencoder, ceph-objectstore-tool, and the mgr's OSDMap.dump(), which the balancer's read modes read them from. #73044 makes the scores cheaper for the callers that still want them.

#72754 complements this. It has pg_autoscaler and the balancer read the osd_map getter instead of building their own dump with OSDMap.dump(), and this PR takes the scores out of that getter. With both, the balancer's upmap mode plans from the getter's dump, which doesn't need the scores. The read and upmap-read modes still plan from osdmap.dump(), which has them.

The new DumpWithReadBalance test in TestOSDMap.cc dumps the map with the default, with with_read_balance true and with it false. It checks that the replicated pool has a read_balance section in the first two dumps and not in the third, and that the EC pool never has one.

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

Signed-off-by: Anthony D'Atri [email protected]
Assisted-by: Claude Opus-5.5

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

Build and test results, on a CentOS Stream 9 container with GCC 11.5, RelWithDebInfo, main at de83537 with #73044, #73045 and #73046 applied:

  • ActivePyModules.cc compiles, and unittest_osdmap passes 45 of 45 tests.
  • osdmaptool --dump json, which still includes the scores, gives output byte-identical to main's.

I haven't run a mgr with this change, so the osd_map getter itself is covered only by the CI runs here.

@anthonyeleven
anthonyeleven marked this pull request as ready for review October 24, 2026 05:57
@anthonyeleven
anthonyeleven requested a review from a team as a code owner October 24, 2026 05:57

@NitzanMordhai NitzanMordhai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, just 1 thing about the unit-tests, can you please add a new test in TestOSDMap.cc that will check the new param is working correctly? Maybe dump JSONFormatter both ways and checks that read_balance shows up only for replicated pools when the flag is true, and never when it's false. That protects the balancer's read mode if someone later flips the default.

@NitzanMordhai

Copy link
Copy Markdown
Contributor

also mention here my PR #72754 those 2 solution complete each other

@github-actions github-actions Bot added the tests label Oct 26, 2026
@anthonyeleven

Copy link
Copy Markdown
Contributor Author

@NitzanMordhai thanks. Both done:

  • Test: 1f3b8ca adds OSDMapTest.DumpWithReadBalance. It dumps with the default, with true and with false, and checks that read_balance appears only for the replicated pool and only in the first two. It passes, along with the other 45 unittest_osdmap tests. With the flag ignored in dump_pool, it fails on pool 2 as it should.
  • mgr: read cached maps in prometheus, pg_autoscaler and balancer #72754: it's mentioned in the description now. I checked the two together: with mgr: read cached maps in prometheus, pg_autoscaler and balancer #72754 the balancer's upmap mode plans from the osd_map getter, which has no scores after this PR but doesn't need them. read and upmap-read go through MsPlan, which still calls osdmap.dump(), so they keep the scores.

@NitzanMordhai NitzanMordhai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath15-testing-20261102.042818-main.

Comment thread src/osd/OSDMap.h Resolved
Comment thread src/osd/OSDMap.h Resolved
@anthonyeleven
anthonyeleven force-pushed the wip-mgr-osd-map-no-read-balance branch from 1f3b8ca to c3936c4 Compare November 2, 2026 15:44
@anthonyeleven anthonyeleven changed the title mgr: leave read balance scores out of the osd_map getter osd/OSDMap: leave read balance scores out of dump by default Nov 2, 2026
@anthonyeleven

Copy link
Copy Markdown
Contributor Author

Rebuilt on main at de83537 with just these two commits, on a CentOS Stream 9 container with GCC 11.5, RelWithDebInfo:

  • unittest_osdmap passes 46 of 46, including DumpWithReadBalance.
  • ActivePyModules.cc, PyOSDMap.cc and OSDMonitor.cc compile.
  • osdmaptool --dump json of the 1,018-OSD map is byte-identical to the previous build's, with a read_balance section for each of its 134 replicated pools.

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

@SrinivasaBharath this changed after it went into wip-bharath15-testing-20261102.042818-main: that batch has 1f3b8ca, and the PR is now at c3936c4.

@github-actions github-actions Bot added the mon label Nov 2, 2026
@anthonyeleven
anthonyeleven force-pushed the wip-mgr-osd-map-no-read-balance branch from c3936c4 to 7081c3f Compare November 2, 2026 21:50
@anthonyeleven anthonyeleven changed the title osd/OSDMap: leave read balance scores out of dump by default mgr: leave read balance scores out of the osd_map getter Nov 2, 2026
@anthonyeleven

Copy link
Copy Markdown
Contributor Author

Back to the previous version: d5cbc07 is 27fdd58 with dump_pool's default argument dropped, as you asked on 10-31, and 7081c3f is the test from 1f3b8ca, unchanged.

@SrinivasaBharath this matches what wip-bharath15-testing-20261102.042818-main has, apart from that default argument, which changes no behavior.

anthonyeleven added a commit to anthonyeleven/ceph that referenced this pull request Nov 3, 2026
Add OSDMap::dump_pools(), which dumps every pool through dump_pool(),
optionally without the read balance scores, and have OSDMap::dump() use
it. dump_pool() takes the same with_read_balance parameter as in ceph#73045.

The osd_map_pools getter now calls dump_pools() instead of open-coding
the pools, and returns the list of pools itself rather than a dict with
a pools key.

Fixes: https://tracker.ceph.com/issues/81783
Signed-off-by: Anthony D'Atri <[email protected]>
Assisted-by: Claude Opus-5.5

@idryomov idryomov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Otherwise LGTM!

Comment thread src/mgr/ActivePyModules.cc Resolved
Comment thread src/test/osd/TestOSDMap.cc Resolved
@anthonyeleven
anthonyeleven force-pushed the wip-mgr-osd-map-no-read-balance branch from 7081c3f to e84c618 Compare November 3, 2026 21:01
@idryomov

idryomov commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Please squash everything into a single commit.

OSDMap::dump computes a read balance score for every replicated pool,
and each score maps every PG of the pool. The mgr's osd_map getter
dumps the map under the GIL whenever a Python module asks for it, so
every module stalls while the scores are computed.

No module needs them there. The balancer gets them from
get_osdmap().dump(), which still includes them, and the mons still
include them in osd dump and osd pool ls detail. Add a
with_read_balance argument to OSDMap::dump, true by default, and to
dump_pool, and have the getter pass false. The dashboard's /api/pool
stops returning the read_balance field it passed through, which
neither its UI nor its OpenAPI spec uses.

TestOSDMap dumps the map with the default, with with_read_balance true
and with it false. The replicated pool must have a read_balance section
in the first two dumps and not in the third, and the erasure-coded pool
never has one. The balancer's read modes rely on the default dump
including the scores.

Fixes: https://tracker.ceph.com/issues/82063
Signed-off-by: Anthony D'Atri <[email protected]>
Assisted-by: Claude Opus-5.5
@anthonyeleven
anthonyeleven force-pushed the wip-mgr-osd-map-no-read-balance branch from a352cc6 to 7208ceb Compare November 5, 2026 22:15
@anthonyeleven

Copy link
Copy Markdown
Contributor Author

Squashed into one commit, 7208ceb. The tree is the same as a352cc6; the commit message now has a paragraph on the test.

@ronen-fr

Copy link
Copy Markdown
Contributor

@idryomov
idryomov merged commit 6461cea into ceph:main Nov 11, 2026
16 checks passed
anthonyeleven added a commit to anthonyeleven/ceph that referenced this pull request Nov 14, 2026
The mirror snapshot and trash purge schedule handlers in rbd_support
each call get_rbd_pools once a minute, even when no schedules exist.
get_rbd_pools fetches osd_map only to read pool ids, names and
applications. Dumping osd_map holds the GIL while it converts every OSD
and every pg_upmap_items entry to Python objects. On a cluster with
10,000 pg_upmap_items entries this stalled other mgr modules for about
6 seconds each minute, before ceph#73045 took the read balance scores out
of the osd_map getter.

Add an osd_map_pools getter that returns the list of pools in osd_map,
each dumped by OSDMap::dump_pool() without the read balance scores, and
use it in get_rbd_pools and resolve_pool_name.

Fixes: https://tracker.ceph.com/issues/81783
Signed-off-by: Anthony D'Atri <[email protected]>
Assisted-by: Claude Opus-5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants