Skip to content

osd/PeeringState: stamp last_clean in pg_stat_t, not pg_history_t - #72912

Merged
batrick merged 2 commits into
ceph:mainfrom
shraddhaag:wip-shraddhaag-last-clean-fastinfo
Oct 23, 2026
Merged

batrick merged 2 commits into
ceph:mainfrom
shraddhaag:wip-shraddhaag-last-clean-fastinfo

Conversation

@shraddhaag

@shraddhaag shraddhaag commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Issue

We see a performance regression with the PR #72144. For small (4K) random writes, we see a significant IOPS regression in crimson:

OSD Block size Before Regression Fix
Crimson + SeaStore 4k 37,776 6,349 (−83.2%) 38,199 (+1.1%)
Crimson + SeaStore 1M 2,256 2,249 (−0.3%) 2,291 (+1.6%)
Classic + BlueStore 4k 54,929 53,190 (−3.2%) 54,231 (−1.3%)
Classic + BlueStore 1M 2,755 2,756 (+0.0%) 2,756 (+0.0%)

Setup: 1 OSD on NVMe (LVM volume), fio rbd engine, randwrite, 8 jobs x iodepth 32, 60 s per run, crimson with --crimson-smp 4. The 1M results are limited by the NVMe device.

Commits: before 91514feb517, regression ff2f4a0d988, fix fa3d949306f(ff2f4a0d988 + fix).

Root Cause

Primary OSD updates last_clean on each write. PR #72144 moved the last_clean field from pg_stat_t into pg_history_t.

_fastinfo only tracks a subset of fields in _info. An update in pg_stat_t is covered by _fastinfo but an update in pg_history_t is not. Since each write updates last_clean in pg_history_t, _fastinfo will in almost all cases will not suffice. We will almost always have to do a complete _info update.

A _fastinfo update is about 194 bytes, while an _info save is about 1110 bytes. On each write op we are writing about 900 bytes more.

I verified the _fastinfo share of PG info saves:

OSD Before Regression Fix
Crimson + SeaStore 99.7% 0% 99.7%
Classic + BlueStore 99.0% 21.7% 99.0%

Impact on Classic

RocksDB appends the pg log entry and the info update. Now instead of _fastinfo it appends _info. The difference is 900 bytes on each write. Since its an append we do not see a huge performance regression.

Impact on Crimson

When Seastore needs to save a _fastinfo, it generally overwrites over the previous _fastinfo entry. But when it needs to save the _info, it needs to find the old _info, mark it removed and then append the new _info. The chain traversal to find the old _info is the extra work that seastore does on each write and hence leads to a large performance impact.

Fix

Move the last_clean field back in pg_stat_t.

When a vulnerability window closes (the first clean publish after the onset), we set pg_history_t.vuln_window_reported and pg_history_t.last_clean to the current time. We do not read pg_stat_t.last_clean, because peering copies pg_stat_t from other OSDs.

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

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.

@jdurgin jdurgin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The fix looks reasonable. This would signicantly affect write amplification for classic in small write workloads as well, which can cause drives to fail faster. This is why everything typically changed in a write is kept in fast_info rather than info.

@shraddhaag
shraddhaag marked this pull request as ready for review October 22, 2026 03:04
@shraddhaag
shraddhaag requested a review from a team as a code owner October 22, 2026 03:04
@shraddhaag
shraddhaag requested a review from rzarzynski October 22, 2026 03:05

@sseshasa sseshasa 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.

The changes look fine to me. This needs a backport to umbrella and so a tracker is warranted here.

@perezjosibm

perezjosibm commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor
PR=wip-perezjos-crimson-only-22-10-2026-PR72912
$ teuthology-suite -s crimson-rados -p 101 --force-priority -c $PR -f debug --filter-out osd-pg-merging,radosbench --suite-branch main --suite-repo https://github.com/ceph/ceph.git
2026-10-22 13:59:39,393.393 INFO:teuthology.suite.run:Test results viewable at 

https://pulpito-ng.ceph.com/jjperez-2026-10-22_13:54:34-crimson-rados-wip-perezjos-crimson-only-22-10-2026-PR72912-distro-debug-trial/

@batrick batrick left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Needs tracker ticket for backport.

@shraddhaag

Copy link
Copy Markdown
Contributor Author

@batrick

batrick commented Oct 22, 2026

Copy link
Copy Markdown
Member

@batrick tracker already exists: https://tracker.ceph.com/issues/81977

Commits should reference it with Fixes: ...

Since 0de8308 ("osd/PeeringState: source the vulnerability-window
latch from pg_history_t"), prepare_stats_for_publish() sets
info.history.last_clean = now on every publish of a clean PG. Stats are
published on every client write (crimson: PG::apply_stats(); classic:
PrimaryLogPG::eval_repop()), so pg_history_t changes on every op.
pg_fast_info_t does not cover pg_history_t, so prepare_info_keymap()
can no longer take the _fastinfo path and writes the full _info on
every write, in both crimson and classic. On SeaStore this also moves
the omap LogManager off its {log entry, _fastinfo} overwrite path.

Stamp pg_stat_t.last_clean on each clean publish instead, as before
0de8308 (it is covered by _fastinfo). A clean publish that does not
close a vulnerability window now leaves pg_history_t unchanged.

The window close must not read pg_stat_t.last_clean: peering copies
pg_stat_t wholesale from other OSDs (Stray::react(MInfoRec),
proc_master_log, update_backfill_progress, split), so a copied value
could close a window early or record a wrong duration. Close the window
on the first publish of a clean PG after the onset instead, timed by
that publish's own clock, and set vuln_window_reported = now.

pg_history_t::merge() now decides if an onset is open against the
merged vuln_window_reported, the same marker prepare_stats_for_publish()
uses, instead of last_clean. last_clean is set to vuln_window_reported
on each close and stays max-merged, so a peer on older code, whose
merge() anchors on it, sees the same open/closed state. The existing
merge_vulnerability_onset_* tests in unittest_osd_types now set
vuln_window_reported, because it is the anchor.

Update the related comments, the pg_vulnerability_duration description
and the TEST_divergent_vulnerability_window comment.

Fixes: https://tracker.ceph.com/issues/81977
Signed-off-by: Shraddha Agrawal <[email protected]>
* unittest_peeringstate: VulnerabilityWindowCleanPublishKeepsHistory
  does clean publishes before any vulnerability window and again after
  a recorded close. It checks that pg_history_t does not change, that
  info is not marked dirty, and that pg_stat_t.last_clean advances. A
  pg_history_t change on a clean publish makes prepare_info_keymap()
  write the full _info instead of _fastinfo on every client write.
* unittest_osd_types: merge_vulnerability_onset_ignores_peer_last_clean
  checks that a peer's later last_clean (older code stamps it on every
  clean publish) does not hide an open, unrecorded onset in merge().

Fixes: https://tracker.ceph.com/issues/81977
Signed-off-by: Shraddha Agrawal <[email protected]>
@shraddhaag
shraddhaag force-pushed the wip-shraddhaag-last-clean-fastinfo branch from 1e86278 to be9ea76 Compare October 22, 2026 14:56
@shraddhaag

Copy link
Copy Markdown
Contributor Author

@batrick done!

@batrick
batrick dismissed their stale review October 22, 2026 15:02

addressed

@batrick

batrick commented Oct 22, 2026

Copy link
Copy Markdown
Member

@shraddhaag please populate the ticket with details.

@perezjosibm perezjosibm moved this from QA in Progress to Tested in Crimson Oct 23, 2026
@batrick
batrick merged commit 11353e0 into ceph:main Oct 23, 2026
16 checks passed
@Matan-B Matan-B moved this from Tested to Merged (Main) in Crimson Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Merged (Main)

Development

Successfully merging this pull request may close these issues.

7 participants