Repository navigation
osd/PeeringState: add perf counters for PG rebuild times - #69578
Merged
sseshasa merged 1 commit intoJul 6, 2026
Merged
Conversation
sseshasa
force-pushed
the
wip-osd-perf-counter-pg-rebuild-stats
branch
from
June 18, 2026 13:19
4ef6a07 to
c13a774
Compare
Contributor
Author
|
Here's an example of how the stats look like: |
ronen-fr
approved these changes
Jun 20, 2026
ronen-fr
left a comment
Contributor
There was a problem hiding this comment.
LGTM with two comments.
sseshasa
force-pushed
the
wip-osd-perf-counter-pg-rebuild-stats
branch
3 times, most recently
from
June 22, 2026 12:38
3b86d5c to
e9c9477
Compare
Track per-OSD PG rebuild duration in prepare_stats_for_publish() (primary OSD only). Three new counters are added to the recoverystate_perf collection: - pg_rebuild_duration: LONGRUNAVG time counter (sum+count pair); This counter internally maintains 'avgcount' that tracks the cumulative number of rebuild events. - pg_rebuild_max_secs: maximum rebuild duration observed in seconds - pg_rebuild_min_secs: minimum rebuild duration observed in seconds The logic uses a per-PG in-memory latch (rebuild_start_time) to capture the redundancy failure entry point. When a PG is first observed to be in a vulnerable state (PG_STATE_DEGRADED, PG_STATE_UNDERSIZED, or num_objects_misplaced/degraded > 0), it latches info.stats.last_change as the start time, provided last_change > last_clean, which ensures only genuine new failures after the prior clean interval are tracked. On recovery, the rebuild duration is computed as (now - rebuild_start_time) and is only recorded if delta num_objects_recovered > 0 or the PG had confirmed redundancy loss at latch time, filtering out spurious state transitions. The latch is cleared after each recorded event. The latch is also cleared in clear_primary_state() so that an interval change or role transition (primary -> replica) does not carry a stale start time or baseline recovered count into a future interval. The new last_degraded is intentionally not used here to retain compatibility with older Ceph branches where the field doesn't exist and requires encoding changes. A future simplification can replace the latch with a direct (last_clean - last_degraded) calculation once last_degraded is consistently available. This interim solution is a close approximation of the PG rebuild time. These counters are scraped per-OSD by ceph-exporter and exposed to Prometheus, enabling durability score calculations over user-defined time windows. Other Changes: 1. Add unit tests to TestPeeringState.cc that exercise the latch logic. 2. Add a standalone integration test to verify that the rebuild perf counters are incremented on the primary OSD after a recovery event. Fixes: https://tracker.ceph.com/issues/77493 Signed-off-by: Sridhar Seshasayee <[email protected]>
sseshasa
force-pushed
the
wip-osd-perf-counter-pg-rebuild-stats
branch
from
June 22, 2026 13:49
e9c9477 to
4d29f4e
Compare
Contributor
|
jenkins test api |
Contributor
Author
|
jenkins test make check |
1 similar comment
Contributor
Author
|
jenkins test make check |
Member
Contributor
Author
|
jenkins test make check |
Contributor
|
jenkins test api |
This was referenced Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Track per-OSD PG rebuild duration in prepare_stats_for_publish() (primary OSD only). Three new counters are added to the recoverystate_perf collection:
pg_rebuild_duration: LONGRUNAVG time counter (sum+count pair); This counter internally maintains 'avgcount' that tracks the cumulative number of rebuild events.pg_rebuild_max_secs: maximum rebuild duration observed in secondspg_rebuild_min_secs: minimum rebuild duration observed in secondsThe logic uses a per-PG in-memory latch (
rebuild_start_time) to capture the redundancy failure entry point. When a PG is first observed to be in a vulnerable state (PG_STATE_DEGRADED,PG_STATE_UNDERSIZED, or num_objects_misplaced/degraded > 0), it latches info.stats.last_change as the start time, provided last_change > last_clean, which ensures only genuine new failures after the prior clean interval are tracked.
On recovery, the rebuild duration is computed as (
now - rebuild_start_time) and is only recorded if deltanum_objects_recovered > 0or the PG had confirmed redundancy loss at latch time, filtering out spurious state transitions. The latch is cleared after each recorded event.The latch is also cleared in
clear_primary_state()so that an interval change or role transition (primary -> replica) does not carry a stale start time or baseline recovered count into a future interval.The new last_degraded is intentionally not used here to retain compatibility with older Ceph branches where the field doesn't exist and requires encoding changes. A future simplification can replace the latch with a direct (
last_clean - last_degraded) calculation once last_degraded is consistently available.This interim solution is a close approximation of the PG rebuild time.
These counters are scraped per-OSD by ceph-exporter and exposed to Prometheus, enabling durability score calculations over user-defined time windows.
Other Changes:
Fixes: https://tracker.ceph.com/issues/77493
Signed-off-by: Sridhar Seshasayee [email protected]
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
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.