Skip to content

crimson/os/seastore: Add Seastore phase latency scaffolding - #69292

Open
perezjosibm wants to merge 1 commit into
ceph:mainfrom
perezjosibm:wip-perezjos-seastore-phase-latency
Open

perezjosibm wants to merge 1 commit into
ceph:mainfrom
perezjosibm:wip-perezjos-seastore-phase-latency

Conversation

@perezjosibm

@perezjosibm perezjosibm commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Implement a light-weight instrumentation for the write path in Seastore:

Seastore already exposes end-to-end operation latency (seastore_op_lat) and a
consecutive-stage breakdown of do_transaction (seastore_do_transaction_stage_lat,
driven by txn_stage_t). Neither answers what kind of work a transaction spends
its time on: everything before submit_transaction arrives as a single BUILD sample.

This adds a complementary, cross-cutting breakdown. A per-transaction
phase_latency_stats_t is fed by an RAII scope timer placed where the work actually
happens, then aggregated per shard and exported as Seastar metrics.

Exported metrics

metric type labels notes
seastore_phase_lat histogram (ms) phase, shard_store_index 12 buckets, 1 µs → 100 ms
seastore_phase_lat_ns counter phase, shard_store_index cumulative ns in the phase
seastore_phase_lat_scopes counter phase, shard_store_index timed scopes; _ns / _scopes = mean cost of one operation

Sub-millisecond bounds are used deliberately: unlike the txn_stage_t histograms these
are fed from steady_clock, and most phases complete in microseconds.

Phases and where they are timed

phase timed at
metadata_lookup onode lookup/create in _do_transaction_step() — seastore.cc (3 sites)
mapping_management clone_range(), remove_mappings_in_range() — transaction_manager.cc
write_packing CPU-side OOL pack/merge before the device write — extent_placement_manager.cc
cache_mutation declared, not yet instrumented (see Known gaps)

Deliberately excluded

Buckets are restricted to work not already measured elsewhere. submit_transaction as a
whole, journal->submit_record and update_lba_mappings are left out because
txn_stage_t::SUBMIT_TOTAL, SUBMIT_JOURNAL and SUBMIT_LBA_UPDATE
(Transaction::phase_durations_t) already time those spans with the same clock. Only the
build-time mapping work is timed here. Likewise write_packing covers only the packing,
not the device writes — those are phase_durations_t::ool_write.

Semantics worth reviewing

  • Nesting: buckets may nest, so per-bucket totals are not expected to sum to the
    transaction latency. A bucket is timed from the outermost enter() to the matching
    outermost exit(), so recursive/concurrent scopes of the same bucket count once.
  • Replays: like phase_durations_t, accumulators survive reset_preserve_handle(),
    so a replayed transaction reports the total cost of all its attempts.
  • Movability: the timer is movable so it can be captured by a continuation and kept
    alive until the future resolves; a plain local would only time the synchronous part of
    a function returning a future.

Grafana dashboard

monitoring/crimson/gen_dashboard.py gains four panels in the SeaStore row (JSON
regenerated; edit the generator, not the JSON):

  • Avg write phase latency by phase — _sum / _count
  • p99 write phase latency by phase — histogram_quantile over _bucket
  • Mean cost of one phase operation — _ns / _scopes
  • Time spent per second by phase — rate(_ns)

Panels are intentionally not stacked, since nested phases overlap.

Overhead

This adds two steady_clock reads to hot per-extent paths (get_pin, alloc_*_extent).
If that proves measurable the timers should be made conditional — feedback welcome on
whether to gate them from the outset.

Known gaps

  • cache_mutation is defined in phase_latency_bucket_t but has no call site yet, so it
    currently reports zero. Kept in the enum as the intended extent alloc/retire bucket.
Screenshot 2026-12-01 at 12 17 45

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.

@perezjosibm
perezjosibm force-pushed the wip-perezjos-seastore-phase-latency branch 4 times, most recently from 7db432f to 8848bc4 Compare June 5, 2026 15:16
@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@perezjosibm
perezjosibm force-pushed the wip-perezjos-seastore-phase-latency branch from 8848bc4 to ce2e6b8 Compare July 6, 2026 15:52
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@perezjosibm
perezjosibm force-pushed the wip-perezjos-seastore-phase-latency branch 2 times, most recently from 2433596 to f2e34ef Compare July 10, 2026 19:36
@perezjosibm
perezjosibm marked this pull request as ready for review July 10, 2026 20:19
@perezjosibm
perezjosibm requested a review from a team as a code owner July 10, 2026 20:19
@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@perezjosibm

perezjosibm commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor Author

@perezjosibm - a general question: some of the functionality seems to be very similar to the perf counters, which are (as far as I can tell) pretty optimized. Is it a good idea to invent a new mechanism?

@ronen-fr This PR does not invent a new mechanism, it simply uses the existing seastore perf counters to measure phases in the write I/O path, with the aim to provide a profile of the latencies/time spent during those phases.

@perezjosibm perezjosibm moved this to Awaits review in Crimson Jul 23, 2026
@perezjosibm
perezjosibm force-pushed the wip-perezjos-seastore-phase-latency branch from f2e34ef to 57cf2ef Compare July 29, 2026 19:00
Copilot AI review requested due to automatic review settings July 29, 2026 19:00

Copilot AI 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.

Pull request overview

Adds transaction-local write-phase latency accounting and per-shard Seastore metrics.

Changes:

  • Adds scoped phase timers and transaction-local accumulation.
  • Instruments mapping, cache, packing, commit, metadata, and durability paths.
  • Exports phase histograms and cumulative counters.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
transaction.h Defines phase buckets, statistics, and scoped timers.
transaction_manager.h Instruments mapping and cache operations.
transaction_manager.cc Instruments mapping updates and durability.
seastore.h Adds per-shard phase metric storage and publishing.
seastore.cc Registers metrics and instruments transaction phases.
extent_placement_manager.cc Measures write-packing work.
Comments suppressed due to low confidence (1)

src/crimson/os/seastore/seastore.cc:2208

  • As above, this local timer is destroyed when the continuation returns, before an asynchronous destination-onode lookup completes. Retain it until get_or_create_onode() resolves so metadata_lookup measures the actual operation.
      auto phase_latency =
          ctx.transaction->record_phase_latency(
            phase_latency_bucket_t::metadata_lookup);

Comment thread src/crimson/os/seastore/seastore.cc Resolved
Comment thread src/crimson/os/seastore/seastore.cc Resolved
Comment thread src/crimson/os/seastore/seastore.cc Resolved
Comment thread src/crimson/os/seastore/seastore.cc Resolved
@perezjosibm

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

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

Could you help me on what steps I can follow to test this PR to check the output? If you could point me to a doc, that would do too! Trying to understand how the latency instrumentation is working in all these recent PRs.

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@github-actions

Copy link
Copy Markdown

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.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Sep 29, 2026
@perezjosibm

Copy link
Copy Markdown
Contributor Author

Could you help me on what steps I can follow to test this PR to check the output? If you could point me to a doc, that would do too! Trying to understand how the latency instrumentation is working in all these recent PRs.

Sorry @shraddhaag: this PR might have been deprecated by the recent performance instrumentation changes, will try rebase and solving the conflicts will point out the redundancies.

@github-actions github-actions Bot removed the stale label Oct 21, 2026
@perezjosibm perezjosibm moved this from Awaits review to In Progress in Crimson Nov 11, 2026
@perezjosibm
perezjosibm force-pushed the wip-perezjos-seastore-phase-latency branch from 57cf2ef to bf7ab59 Compare November 12, 2026 13:09
@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@perezjosibm
perezjosibm force-pushed the wip-perezjos-seastore-phase-latency branch from bf7ab59 to d9fc755 Compare November 25, 2026 14:56
@perezjosibm
perezjosibm force-pushed the wip-perezjos-seastore-phase-latency branch from d9fc755 to 902dfb6 Compare November 27, 2026 11:37
@perezjosibm
perezjosibm requested a review from a team as a code owner November 27, 2026 11:37
@perezjosibm perezjosibm moved this from In Progress to Awaits review in Crimson Dec 1, 2026
txn_stage_t splits do_transaction into consecutive stages, which shows
where a transaction spends its time but not what kind of work that time
goes into: everything before submit_transaction is reported as a single
BUILD sample.

Add a complementary, cross-cutting breakdown: a per-transaction
phase_latency_stats_t fed by an RAII scope timer placed where the work
actually happens (onode lookups, LBA mapping operations, Cache extent
alloc/retire, OOL write packing), aggregated into the new
seastore_phase_lat histogram plus seastore_phase_lat_ns /
seastore_phase_lat_scopes counters, labelled by phase.

The buckets are restricted to work that is not already measured
elsewhere.  submit_transaction as a whole, journal->submit_record and
update_lba_mappings are left out because txn_stage_t::SUBMIT_TOTAL,
SUBMIT_JOURNAL and SUBMIT_LBA_UPDATE (Transaction::phase_durations_t)
already time exactly those spans with the same clock; only the
build-time mapping work is timed here.

Like phase_durations_t, the accumulators use steady_clock and survive
reset_preserve_handle(), so a replayed transaction reports the total
cost of all its attempts.  Histogram buckets are initialised in
register_metrics() following the op_lat/stage_lat pattern, with
sub-millisecond bounds since these phases are usually microseconds.
Buckets may nest, so their totals are not expected to sum to the
transaction latency.

Note that this adds two steady_clock reads to hot per-extent paths
(get_pin, alloc_*_extent); if that proves measurable, the timers should
be made conditional.

Co-Authored-By: Claude Opus 5 <[email protected]>
Signed-off-by: Jose J Palacios-Perez <[email protected]>
@perezjosibm
perezjosibm force-pushed the wip-perezjos-seastore-phase-latency branch from 902dfb6 to 97bd139 Compare December 2, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: New
Status: Awaits review

Development

Successfully merging this pull request may close these issues.

4 participants