Skip to content

seastore: add latency distribution (p95/p99) support - #69281

Merged
Matan-B merged 6 commits into
ceph:mainfrom
Matan-B:wip-matanb-seastore-p95
Jun 15, 2026
Merged

Matan-B merged 6 commits into
ceph:mainfrom
Matan-B:wip-matanb-seastore-p95

Conversation

@Matan-B

@Matan-B Matan-B commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

This is a follow up to the discussion from: #68691 (comment)

Commits:


[1]
Previous work observed ~5–10% conflict rates with a clear correlation to average latency, but lacked visibility into latency distribution and tail behavior.

This change adds histogram buckets for DO_TRANSACTION latency, enabling p95/p99 analysis.
Initial results show higher-conflict shards have a heavier tail, not just higher averages (will share in the comments below).

Pre:

            "seastore_op_lat": {
                "latency": "DO_TRANSACTION",
                "shard": "0",
                "shard_store_index": "0",
                "value": {
                    "sum": 259383,
                    "count": 281545,
                    "buckets": [
                        {
                            "le": "+Inf",
                            "count": 281545
                        }

Post:

            "seastore_op_lat": {
                "latency": "DO_TRANSACTION",
                "shard": "0",
                "shard_store_index": "0",
                "value": {
                    "sum": 136694026,
                    "count": 128313,
                    "buckets": [
                        {
                            "le": 250,
                            "count": 11569
                        },
                        {
                            "le": 500,
                            "count": 35328
                        },
                        {
                            "le": 1000,
                            "count": 37047
                        },
                        {
                            "le": 1500,
                            "count": 17869
                        },
                        {
                            "le": 2000,
                            "count": 9890
                        },
                        {
                            "le": 3000,
                            "count": 9587
                        },
                        {
                            "le": 5000,
                            "count": 5139
                        },
                        {
                            "le": 7500,
                            "count": 1317
                        },
                        {
                            "le": 10000,
                            "count": 368
                        },
                        {
                            "le": 15000,
                            "count": 166
                        },
                        {
                            "le": 20000,
                            "count": 26
                        },
                        {
                            "le": 30000,
                            "count": 6
                        },
                        {
                            "le": 50000,
                            "count": 1
                        },
                        {
                            "le": 100000,
                            "count": 0
                        },
                        {
                            "le": "+Inf",
                            "count": 128313
                        }

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.

Matan-B added 2 commits June 4, 2026 09:39
Initialize lat_hist_bounds_us bucket boundaries (0.25ms–20ms in 10
log-ish steps) for the op_lat Seastar histogram in register_metrics(),
and populate them in add_latency_sample(). Previously op_lat only
tracked sample_count and sample_sum, giving an average but no
percentile visibility.

Signed-off-by: Matan Breizman <[email protected]>
Sub-ms ops rounded to zero under the old millisecond cast, making
the average meaningless for fast NVMe workloads. sample_sum is now
in microseconds; divide by 1000 for ms average.

Signed-off-by: Matan Breizman <[email protected]>
@Matan-B
Matan-B requested a review from a team as a code owner June 4, 2026 09:46
@Matan-B Matan-B added this to Crimson Jun 4, 2026
@Matan-B Matan-B moved this to Awaits review in Crimson Jun 4, 2026
@Matan-B

Matan-B commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author
shard conflict_% per_1k avg_ms p50_ms p90_ms p99_ms tail_amp (p99 / p50)
0 2.51 25 1.1 1.0 3.0 10.0 10x
1 3.26 33 1.3 1.5 5.0 20.0 13x
2 8.29 83 7.1 5.0 20.0 80.0 16x
3 4.51 45 2.3 1.5 5.0 25.0 16x
4 5.37 54 3.0 1.5 10.0 40.0 27x
5 3.79 38 1.5 1.5 5.0 20.0 13x
6 3.57 36 1.3 1.5 5.0 20.0 13x
7 8.31 83 4.8 5.0 20.0 80.0 16x

We’re seeing two distinct failure modes driven by conflict rate:

A) spiky behavior

Shard examples: 3–5 range (especially shard 4)

Characteristics:

  • Conflict ~4–6%
  • p50 still low (~1–1.5 ms)
  • Avg rising (~2–3 ms)
  • p90 increases (~5–10 ms)
  • High tail amplification (up to ~27x)

some requests experience significant latency spikes - average is still mostly ok.

B) fully degraded / contention collapse

Shard examples: 2 and 7

Characteristics:

  • Conflict ~8%+
  • p50 elevated (~5 ms)
  • Avg high (~5–7 ms)
  • p90 ~20 ms
  • Large tail (50–100 ms)

All requests are consistently slow, not just spiky.


There seem to be a "clear" threshold around ~5% conflict:

  • Below - stable behavior
  • Around - instability begins (Mode A)
  • Above - rapid degradation (Mode B)

A small increase in conflict rate causes a nonlinear impact from mostly fast operations with occasional spikes to consistently slow performance driven by retries and contention, with a tipping point around ~5%.

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

Good idea to have these at the seastore level. I was thinking you might already have the client-level stats from fio, since its default output includes latency histograms from the client perspective.

@jdurgin

jdurgin commented Jun 4, 2026

Copy link
Copy Markdown
Member

Is each shard processing the same number of IOPS? I wonder if we're seeing side effects of workload imbalance as well in those latency numbers (perhaps more workload leading to higher conflicts, to some degree too). Even in the low cases p99 latency being 10x is quite high. To dig into those low conflict cases we'll probably need a lot more fine-tuned metrics measuring where latency is coming from for a given op.

Add a num_replays counter to Transaction, incremented in
Cache::mark_transaction_conflicted whenever a transaction is marked
conflicted.

Only relevant for user-MUTATE path (do_transaction_no_callbacks).

Signed-off-by: Matan Breizman <[email protected]>
@Matan-B

Matan-B commented Jun 7, 2026 •

Copy link
Copy Markdown
Contributor Author

per-shard MUTATE volume seems eve. Conflict rate ranges ~1% to 5% and avg DO_TRANSACTION latency ranges similarly:

shard created-MUTATE conflict rate avg lat p50 lat
0 260,744 5.3% 9.96 ms 7.5 ms
1 266,302 3.6% 6.75 ms 3.0 ms
4 246,794 2.2% 2.33 ms 1.0 ms
7 238,115 1.7% 1.79 ms 1.0 ms
2 250,319 1.7% 1.64 ms 1.0 ms
3 244,826 1.5% 1.12 ms 1.0 ms
5 249,206 1.4% 1.20 ms 1.0 ms
6 244,624 1.2% 0.95 ms 1.0 ms

(conflict rate = invalidated-MUTATE / created-MUTATE)
(this is without #69211 so the conflict rate is ~double - but the avg lat / p50 remains the same)

I'm going to move forward with this PR, to track per-transaction retry counts (I don't see a reason to merge until the investigation is over). The idea here is to consider an "anti-starvation" mechanism if it turned out that starved commits keep getting invalidated and explain the tail lat.

Retry distribution on the busiest shard (shard 0) in another run:

retries txns share
0 111,752 90.5%
1 10,223 8.3%
2 1,264 1.0%
3+ 307 0.25%

(deepest seen was 8 retries, by a single txn, there is no long starvation tail)

We might be able to rule out conflicts as the cause:

  • 90%+ of transactions even on the worst shard commit are with zero retries and there's no starvation tail.
  • The worst shard is slower also at the median (p50 ~7.5ms vs ~1ms), and the median txn has zero retries, so the latency is hitting ordinary no-retry ops, which conflicts can't explain.

It's likely that conflicts (and the retry tail) are a result of how loaded a shard is, not the cause.
Anti-starvation isn't worth it for latency right now (as it only affect the ~0.25% 3+ retry deep tail).


I think we need to see where the per-op time actually goes. I'll try to add a per-stage latency counters around do_transaction, collection-lock wait, throttler wait and submit/journal - so we can separate queuing from real work (perhaps cache misses widen the conflict window).

Introduce a new latency breakdown metric for do_transaction, exposing
per-stage timing (build, collock_wait, submit, throttler_wait).

Signed-off-by: Matan Breizman <[email protected]>
@Matan-B

Matan-B commented Jun 7, 2026 •

Copy link
Copy Markdown
Contributor Author

Followup to the Per-stage stats (all is same workload as before)

shard conf% col_lock throttler build submit all stages e2e avg
0 7.8% 1926 0.1 1152 2285 5363 5592
4 7.4% 1306 0.1 787 1590 3684 3880
5 4.9% 474 0.0 508 1153 2135 2232
3 3.9% 433 0.0 439 1006 1878 1960
6 4.9% 280 0.0 470 1200 1950 2031
1 5.1% 307 0.0 477 1211 1995 2079
7 3.1% 216 0.0 431 1168 1815 1873
2 3.4% 126 0.0 320 862 1308 1354

collock_wait is by far the dominant source of any imbalance. Shards 0 and 4 (highest collock, highest conflict) are the slow ones. shard 2 (lowest collock) is the fastest.

This could either be Seastore's mishandling collection-lock hold time which might be needed to release earlier (if possible).

Alternatively, pg mapping might be skewed (above SeaStore) since many hot pgs land on the same shard (see 0 and 4 in the test above).

@perezjosibm

perezjosibm commented Jun 7, 2026 •

Copy link
Copy Markdown
Contributor

I think we need to see where the per-op time actually goes. I'll try to add a per-stage latency counters around do_transaction, collection-lock wait, throttler wait and submit/journal - so we can separate queuing from real work (perhaps cache misses widen the conflict window).

@Matan-B I've been struggling to define a per component attribution in this draft pr: #69292 if you could please help to make it work would be very much appreciated
Out of curiosity, what is the workload used above (I guess random write 4k)?

@Matan-B

Matan-B commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

@Matan-B I've been struggling to define a per component attribution in this draft pr: #69292 if you could please help to make it work would be very much appreciated

Hey Jose, I'm breaking down the collection lock hold first, since I suspect it's more straight forward to improve.
Seems #69292 nicely breaks the build side (metadata_lookup/cache_mutation), which is parallel to this PR.

I think that improving build/_do_transaction_step likely needs #68691, and I'm trying to undersatnd whether that complexity is worth it. However, if your breakdown shows cheaper win, we can also try that route.

Out of curiosity, what is the workload used above (I guess random write 4k)?

Yes, workload shared here: #68691 (comment)

I've been struggling to define a per component attribution

I'm not sure I follow here, but we can keep expanding phase_durations_t suggested here if that is the question.


Sharing the sub-phase breakdown (last commit):

sh col_lock build s_reserve s_ool_write s_lba s_prep_enter s_prep_record s_journal s_total throttler
0 83 347 2 474 18 2 21 586 1153 0
1 73 329 3 446 18 0 21 548 1082 0
2 595 599 9 627 26 4 22 757 1515 0
3 471 725 13 773 32 2 26 981 1942 0
4 240 394 3 459 21 0 20 524 1076 0
5 474 595 12 661 26 2 23 832 1637 0
6 79 311 3 416 16 0 19 496 993 0
7 1216 965 23 789 46 24 25 950 1991 0

The col lock hold is ~50% build + ~45% s_ool_write (write_delayed_ool_extents + write_preallocated_ool_extents). For this PR I think that's enough breakdown, the open question is whether we can move the OOL device-write wait out of the col lock window.

we might be able to reduce onode lookup stage by storing the prev
lookup already made when getting the obc.

according to to the stats I've colleceted onode lookup takes 40%
of total build time (which is ~20% of total txn time)

Signed-off-by: Matan Breizman <[email protected]>
@Matan-B

Matan-B commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor Author

I've started to break down build phase as well with collecting onode lookup as well.
Seems Onode lookup takes almost 40% of build time which is ~20% of all txn stages.
Reducing this might largely help, this can be done by re-using the onode lookup we already do at obc (with/load_obc) creation time as suggested by Xuehan. @xxhdx1985126, I'll try to look into this, obc_loader seems like a good candidate to be aware of Onode lookups.

@perezjosibm

Copy link
Copy Markdown
Contributor
  • Shaman build (in progress): wip-perezjos-crimson-only-11-06-2026-PR69281

@Matan-B

Matan-B commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

@Matan-B
Matan-B merged commit 123fa4c into ceph:main Jun 15, 2026
6 checks passed
@Matan-B Matan-B moved this from Needs QA to Merged (Main) in Crimson Jun 15, 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