Skip to content

osd/scheduler: Classify subOp reads according to op priority for mClock - #64618

Merged
sseshasa merged 8 commits into
ceph:mainfrom
sseshasa:wip-fix-mclock-slow-ops-during-recovery
Jun 12, 2026
Merged

sseshasa merged 8 commits into
ceph:mainfrom
sseshasa:wip-fix-mclock-slow-ops-during-recovery

Conversation

@sseshasa

@sseshasa sseshasa commented Jul 22, 2025 •

Copy link
Copy Markdown
Contributor

The change brings MSG_OSD_EC_READ into the fold of mClock scheduler. This
improves the scheduling of client and other classes of operation as they
are no longer unnecessarily preempted by the 'immediate' queue.
EC SubOps are now handled as follows:

  • EC SubOp reads generated during recovery will either go into the
    'background_recovery' or 'background_best_effort' class based on
    the recovery priority set for the op. EC SubOp reads generated due
    to client will continue to be classified as 'immediate'.

  • EC SubOp writes generated as a result of client operations will
    continue to be classified as 'immediate'.

  • EC SubOp replies are considered high priority and therefore
    continue to be classed as 'immediate'.

Fixes: https://tracker.ceph.com/issues/71655
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 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

@sseshasa
sseshasa requested a review from a team as a code owner July 22, 2025 14:16
@sseshasa
sseshasa requested review from athanatos and rzarzynski July 22, 2025 14:16
@sseshasa sseshasa changed the title osd/scheduler: Classify subOp reads/writes according to op priority for mClock (WIP)osd/scheduler: Classify subOp reads/writes according to op priority for mClock Jul 22, 2025
@sseshasa
sseshasa force-pushed the wip-fix-mclock-slow-ops-during-recovery branch 2 times, most recently from 53d7eee to 970a76e Compare July 29, 2025 13:12
Comment thread src/osd/scheduler/mClockScheduler.cc Resolved
Comment thread src/osd/scheduler/mClockScheduler.cc Resolved
@sseshasa

Copy link
Copy Markdown
Contributor Author

@athanatos Following up from our discussion, I think I understand what needs to change when determining the cost for a subOpRead. In ECBackendL::RecoveryBackend::continue_recovery_op(), the amount in the RecoveryOp::IDLE: case is set by calling get_recovery_chunk_size() (see:

uint64_t amount = get_recovery_chunk_size();
).

For mClock this should be changed to return the object size being recovered and rounded up to the stripe width. Otherwise, this will always be set close to the recovery chunk size (~8 MiB) which is incorrect. Do you agree with this?

Comment thread src/osd/scheduler/OpSchedulerItem.h Resolved
Comment thread src/messages/MOSDECSubOpRead.h Resolved
Comment thread src/osd/ECMsgTypes.cc Resolved
@athanatos

Copy link
Copy Markdown
Contributor

@athanatos Following up from our discussion, I think I understand what needs to change when determining the cost for a subOpRead. In ECBackendL::RecoveryBackend::continue_recovery_op(), the amount in the RecoveryOp::IDLE: case is set by calling get_recovery_chunk_size() (see:

uint64_t amount = get_recovery_chunk_size();

).
For mClock this should be changed to return the object size being recovered and rounded up to the stripe width. Otherwise, this will always be set close to the recovery chunk size (~8 MiB) which is incorrect. Do you agree with this?

Ah, we submit ECSubRead with the max amount and trust the other side to truncate. There are cases where it has to work that way -- the first request may not actually know the object size since it doesn't have object info xattr yet. I don't think this is worth messing with for now, just use the value actually in the ECSubRead. We can make it more accurate in a followup PR.

@sseshasa

Copy link
Copy Markdown
Contributor Author

Ah, we submit ECSubRead with the max amount and trust the other side to truncate. There are cases where it has to work that way -- the first request may not actually know the object size since it doesn't have object info xattr yet. I don't think this is worth messing with for now, just use the value actually in the ECSubRead. We can make it more accurate in a followup PR.

Sure, I will calculate the value from ECSubRead's std::map<hobject_t, std::list<boost::tuple<uint64_t, uint64_t, uint32_t> >> to_read to calculate the cost. I will address your other comments as well.

@sseshasa
sseshasa force-pushed the wip-fix-mclock-slow-ops-during-recovery branch 2 times, most recently from 9c05224 to eabf257 Compare July 29, 2025 18:48
@sseshasa
sseshasa force-pushed the wip-fix-mclock-slow-ops-during-recovery branch from eabf257 to c7429e0 Compare August 11, 2025 12:56
@sseshasa sseshasa changed the title (WIP)osd/scheduler: Classify subOp reads/writes according to op priority for mClock osd/scheduler: Classify subOp reads/writes according to op priority for mClock Aug 11, 2025
@sseshasa
sseshasa force-pushed the wip-fix-mclock-slow-ops-during-recovery branch 2 times, most recently from 311f0d7 to 06235e6 Compare August 11, 2025 13:44
@sseshasa

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@sseshasa

Copy link
Copy Markdown
Contributor Author

jenkins test api

@sseshasa

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@sseshasa

Copy link
Copy Markdown
Contributor Author

jenkins test windows

1 similar comment
@sseshasa

Copy link
Copy Markdown
Contributor Author

jenkins test windows

@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

@sseshasa
sseshasa force-pushed the wip-fix-mclock-slow-ops-during-recovery branch from b5c1a48 to d17e764 Compare May 21, 2026 13:54
@sseshasa

Copy link
Copy Markdown
Contributor Author

The latest push (May 21, 2026) adds a bunch of perf counters to help track the queue length and latency of different ops handled within mClock queue and the high_queues. This would be helpful in tracking down issues observed if any during disruptive operations with EC based clusters.

Testing Progress Notes

  1. I am testing the changes on ec2+1 and ec4+2 profiles on a NVMe based cluster. (80% completed).
  2. Unfortunately, HDDs are not yet available on the machines in the new lab and so I have to engage the testing team for this.
  3. But specific data from the current test results would be useful indicators (for e.g. client latency differences between runs with and without fix) on how the fix is helping.
  4. Once the test runs complete (early next week), I will update the results and comparison.
  5. Teuthology test runs look good (will update the results as well here).
  6. Once the reviews are complete, the plan is to test the fix on a larger HDD based cluster before merging this upstream and downstream.
  7. This fix can be tested by upstream users if possible and it would be great to hear feedback.

@sseshasa

sseshasa commented May 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Optimizing Erasure Coded Sub-Op Read Scheduling Under mClock - Test Report

1. Summary

During the execution of concurrent client workloads and background backfill operations on Erasure Coded (EC) pools, slow Ops along with client tail latency degradation was observed. Slow ops were reported because client ops were preempted by a surge of EC subOp reads in the higher priority 'immediate' queue due to marking an OSD 'OUT' for draining. This report evaluates a two-fold solution combining a Cost Fix with mClock Profile Allocation Adjustments on an NVMe based Ceph cluster.

Across all three standard profiles (high_client_ops, balanced, and high_recovery_ops), the combined solution successfully eliminated Primary OSD lock contention, stabilized background data movement pacing, and compressed client tail latencies below cluster baselines.

2. Test Environment

Nodes: 1 Nos, Architecture: x86_64, 192 Cores, 500 GiB Memory
OSDs: 7 OSDs, Created on 1:1 Mapping on NVMe devices (Model: SAMSUNG MZQL27T6HBLA-00A07)
EC Profile: 4+2, plugin=isa technique=reed_sol_van
IO Tool: Fio, QD: 64
Tested with ~130K Objects with object sizes in range 1 KiB - 16 MiB.

NOTE: The Fio client was configured to run at 80% of the maximum measured benchmark to simulate a realistic workload.

3. Problem Statement & Root Cause

The first part of the solution simply redirected the EC subOp reads to the appropriate 'background-recovery' or the 'background-best-effort' queue based on the recovery priority. But on EC pools configured with legacy chunk layout handling (allow_ec_optimizations: false), moving EC sub-op reads (MSG_OSD_EC_READ) from the unthrottled immediate queue to mClock background queues exposed a critical structural bottleneck:

  1. The background_best_effort queue (where backfills are enqueued) carried a 0% (MIN) reservation. Dense client traffic completely starved this queue, indefinitely extending lock retention windows.

  2. While subOp reads sat starved in replica OSD mClock queues, the Primary OSD remained blocked waiting for replies, continuously holding internal BlueStore transactions, Placement Group (PG), and Object locks. Incoming client operations bypassed the mClock queue cleanly but stalled at the object layer waiting for backend transaction locks to drop, causing latency inflation.

The results of the tests with the cost fix but unmodified profile allocations shared below.

3.1. Test Results with Cost Fix Alone & Comparison With Baseline (No Fix)

With a 0% default reservation caused backfills to be starved whenever client traffic peaked. This starvation forced the Primary OSD to hold internal object and transaction locks open for too long. Client requests passed through mClock instantly, but immediately encountered those backend lock blockades, which is why the 50th percentile spiked to 5.210 ms. This test proved that fixing the cost alone was not enough; a nominal reservation floor was absolutely mandatory to cleanly flush the locks.

Client Performance Matrix (Cost Fix alone)

Metric Baseline (No Fix) Cost Fix Alone Performance Status vs. Baseline
Throughput (IOPS) 8647.94 8628.89 Minor Workload Slump
Avg clat (msec) 5.455 6.206 Degraded (+25.75% Latency Inflation)
50th pctl (msec) 4.492 5.210 Degraded (+29.05%)
95th pctl (msec) 11.469 13.041 Degraded (+26.10%)
99.5th pctl (msec) 21.050 23.199 Degraded (+17.52%)

4. Implemented Solutions

The following solution which is two-fold was implemented:

  1. Set cost for EC recovery reads: The cost function was written to compute the exact physical byte footprint of full or fragmented chunks linearly. It maps the memory allocations exactly once and scales it directly against the read extent count.

  2. Profile allocation tuning: To establish an unstarvable queue that allows background subOps to clear quickly and drop primary locks, the background_best_effort profile settings were updated globally:

    • high_client_ops: res = 5% [was 0%], wgt = 4 [was 1], lim = 70%
    • balanced: res = 5% [was 0%], wgt = 2 [was 1], lim = 90%
    • high_recovery_ops: res = 5% [was 0%], wgt = 2 [was 1], lim = MAX

5. Performance Results

5.1. Profile 1: balanced Performance

Comparison Charts

balanced_profile_Avg_Client_Latency_Comparison_During_Misplaced_Recovery_NVMe balanced_profile_Avg_Misplaced_Objects_Recovered_Time_Taken_NVMe balanced_profile_Recovery_Throughput_Comparison

Client Performance Matrix (Comparison)

Metric Baseline (No Fix) Combined Solution (Cost Fix + Profile Mod) Delta (Combined vs Baseline)
Throughput (IOPS) 8647.94 8649.02 +0.01% [Stable]
Avg clat (msec) 5.455 4.937 -9.49% [Improvement]
50th pctl (msec) 4.492 4.047 -9.91% [Improvement]
95th pctl (msec) 11.469 10.715 -6.57% [Improvement]
99.5th pctl (msec) 21.050 21.313 +1.25% [Stable]

Observed Improvements:

  • Client completion latency fell by 9.49% and median latency fell by 9.91%, proving that the 5% reservation successfully flushed subOps to release primary locks and optimize client Ops.
  • Backfill speed: The erratic baseline bursts (stdev = 31.46) was controlled down to 13.24 (a 57.92% stabilization), preventing device queues from thrashing.
  • Elimination of Object Bloat: Mean objects recovered dropped by 15.96% because unblocking backfill ops eliminated ongoing client/backfill state re-mappings.

5.2. Profile 2: high_client_ops Performance

Comparison Charts

high_client_ops_profile_Avg_Client_Latency_Comparison_During_Misplaced_Recovery_Test_NVMe high_client_ops_profile_Avg_Misplaced_Objects_Recovered_Time_Taken_NVMe high_client_ops_profile_Recovery_Throughput_Comparison

Client Performance Matrix (Comparison)

Metric Baseline (No Fix) Combined Run (Cost Fix + Profile Mod) Delta (Combined vs Baseline)
Throughput (IOPS) 8649.75 8647.13 -0.03% [Stable]
Avg clat (msec) 4.935 4.593 -7.01% [Improvement]
50th pctl (msec) 4.037 3.854 -4.53% [Improvement]
95th pctl (msec) 10.342 9.287 -10.20% [Improvement]
99.5th pctl (msec) 19.740 18.494 -6.31% [Improvement]

Observed Improvements:

  • Latency Compression: The results show a reduction in average clat and pushed median (50th) latency to an all-time low of 3.854 ms showing that the combined fix successfully clears out the lock delays.
  • Tail Stabilization: The two-fold fix preserves strong tail compression at the 95th and 99.5th percentiles while stabilizing backfill delivery down to a standard deviation of 15.71.

5.3. Profile 3: high_recovery_ops Performance

Comparison Charts

high_recovery_ops_profile_Avg_Client_Latency_Comparison_During_Misplaced_Recovery_Test_NVMe high_recovery_ops_profile_Avg_Misplaced_Objects_Recovered_Time_Taken_NVMe high_recovery_ops_profile_Recovery_Throughput_Comparison

Client Performance Matrix (Comparison)

Metric Baseline (No Fix) Combined Run (Cost Fix + Profile Mod) Delta (Combined vs Baseline)
Throughput (IOPS) 8638.32 8648.95 +0.12% [Stable]
Avg clat (msec) 4.802 4.904 +2.12% [Stable & Within Device Margin]
50th pctl (msec) 4.027 4.165 +3.42% [Stable & Within Device Margin]
95th pctl (msec) 9.863 9.896 +0.33% [Stable]
99.5th pctl (msec) 18.743 18.691 -0.28% [Improvement]

Observed Improvements:

  • Preserve Client Performace: The 30% default client reservation pre-throttled incoming writes, completely insulating client median (4.165 ms) and tail (18.691 ms) latencies from background activity. There was a negligible increase in the clat and tail latency with the introduction of a weight of 2 and 5% reservation. The performance of this profile is largely preserved.

6. Fix Compatibility & Hardware Adaptability

This combined solution is compatible across both Flash (SSD/NVMe) and Hard Drive (HDD) environments:

  • On SSD/NVMe: The two-fold solution maximizes parallel flash channel utilization, translating directly into lower average client completion metrics as observed in the performance results.

  • On HDDs: The combined solution feeds mClock accurate physical byte footprints. This keeps mClock tag intervals tight and accurate. Paired with the dedicated, stable 5% reservation floor, mClock can cleanly interleave client blocks and backfill fragments in predictable time slices. This should help preserve native drive pacing, prevent thrashing, and ensure stable throughput. Tests on HDD environment is the next step which will help validate the solution further.

7. Conclusion & Next Steps

As seen in the results, the combined solution works well in terms of isolating client and backfill traffic and prevent one class of operation from indirectly blocking another within the PG & BlueStore layers.

Although not tested in the current effort, the modified reservation and weight parameters of the background-best-effort class should help other types of best-effort operations like scrub and snaptrim to also perform better. If these operations abuse the slightly expanded weight/reservation configuration, there are existing safe guards to limit them from running away unchecked.

Therefore, this fix acts as a good starting point to address some outstanding issues with mClock's background operation scheduling with more fixes coming up.

@sseshasa
sseshasa force-pushed the wip-fix-mclock-slow-ops-during-recovery branch from d17e764 to 483fb37 Compare May 26, 2026 12:53
@sseshasa sseshasa changed the title [WIP] osd/scheduler: Classify subOp reads according to op priority for mClock osd/scheduler: Classify subOp reads according to op priority for mClock May 26, 2026
@sseshasa
sseshasa force-pushed the wip-fix-mclock-slow-ops-during-recovery branch from 483fb37 to d874a80 Compare June 4, 2026 07:00
@sseshasa
sseshasa requested a review from a team as a code owner June 4, 2026 07:00
@sseshasa

sseshasa commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

Teuthology Test Result

https://pulpito.ceph.com/sseshasa-2026-05-26_18:29:48-rados-wip-sseshasa-testing-2026-05-26-1779803771-distro-default-trial/
270/295 Passed, 25 Failed

All Failures are Known and Unrelated

  1. ['238505'] - https://tracker.ceph.com/issues/76298 - rados/thrash-erasure-code failure - not all PGs are active or peered (RADOS)
  2. ['238488', '238356'] - https://tracker.ceph.com/issues/76297 - test_iscsi_container - cephadm/test_iscsi_setup.sh fails on sudo ls /dev/disk/by-path - (Orchestrator)
  3. ['238486'] - https://tracker.ceph.com/issues/75488 - qa/standalone/osd/osd-recovery-prio.sh: TEST_recovery_pool_prio: The primary PG for testX didn't become the in progress item [on remote] - (RADOS)
  4. ['238478', '238413', '238284'] - https://tracker.ceph.com/issues/76497 - rados/singleton-bluestore/cephtool - evicting unresponsive client warnings - (RADOS)
  5. ['238446'] - https://tracker.ceph.com/issues/65719 - debian-17.2.6 jammy repository does not have a Release file - (RADOS)
  6. ['238445'] - https://tracker.ceph.com/issues/76473 - rados/valgrind-leaks: expected valgrind issues and found none - (RADOS)
  7. ['238434] - https://tracker.ceph.com/issues/76981 - Rocky10 - test_cephadm.sh failure cause by Cannot register NFS V3 on TCP - (Orchestrator)
  8. ['238427'] - https://tracker.ceph.com/issues/74827 - rados/standalone/mon/misc.sh - TEST_mon_features return 1 (RADOS)
  9. ['238399', '238251'] - https://tracker.ceph.com/issues/75414 - upgrade: pool full warning variation - (RADOS)
  10. ['238395', '238244'] - https://tracker.ceph.com/issues/70669 - ERROR: test_list_enabled_module: cephfs resource temporarily unavailable - (Dashboard)
  11. ['238346'] - https://tracker.ceph.com/issues/72888 - rados/singleton-bluestore cluster [ERR] overall HEALTH_ERR 1 auth entities have invalid capabilities - (Ceph)
  12. ['238338'] - https://tracker.ceph.com/issues/76470 - rados/test_crash.sh: Induced crashes are not properly posted - (RADOS)
  13. ['238323'] - https://tracker.ceph.com/issues/74794 - rados/thrash - The WatchDog barked due to Thrasher ceph.osd.9 threw exception wait_for_recovery: failed before timeout expired - Many PGs stuck not active+clean - (RADOS)
  14. ['238300', '238243', '238242', '238294'] - https://tracker.ceph.com/issues/74708 - Failed to download metadata for repo 'epel' causes 'sudo yum install -y kernel' to fail on trial129
  15. ['238291', '238271'] - https://tracker.ceph.com/issues/71344 - Monitor Reconnection Failure and MON_NETSPLIT due to Stale Global Sequence Check During Incoming ConnectionMonitor Reconnection Failure and MON_NETSPLIT due to Stale Global Sequence Check During Incoming Connection - (RADOS)
  16. ['238245'] - https://tracker.ceph.com/issues/74074 - ceph-dencoder - failed with 20.3 corpus repo - (RADOS)

@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

@sseshasa
sseshasa force-pushed the wip-fix-mclock-slow-ops-during-recovery branch from d874a80 to ed77fc2 Compare June 11, 2026 03:59
Comment thread src/common/mclock_common.cc Resolved
Comment thread src/osd/scheduler/mClockScheduler.cc Resolved
Comment thread src/osd/scheduler/OpSchedulerItem.h Resolved
Comment thread src/messages/MOSDECSubOpRead.h Resolved
Comment thread src/osd/ECBackendL.cc Resolved
Comment thread src/osd/ECCommonL.cc Resolved
Comment thread src/osd/ECMsgTypes.cc Resolved
sseshasa and others added 8 commits June 12, 2026 12:26
The earlier output formatting was resulting in the value and string
representation of the SchedulerClass being clubbed together for
e.g., "3client"

The formatting is now fixed to log SchedulerClass as "3 (client)".

Signed-off-by: Sridhar Seshasayee <[email protected]>
…Clock

The change brings MSG_OSD_EC_READ into the fold of mClock scheduler. This
improves the scheduling of client and other classes of operation as they
are no longer unnecessarily preempted by the 'immediate' queue.
EC SubOps are now handled as follows:

 - EC SubOp reads generated during recovery will either go into the
   'background_recovery' or 'background_best_effort' class based on
   the recovery priority set for the op. EC SubOp reads generated due
   to client will continue to be classified as 'immediate'.

 - EC SubOp writes generated as a result of client operations will
   continue to be classified as 'immediate'.

 - EC SubOp replies are considered high priority and therefore
   continue to be classed as 'immediate'.

Fixes: https://tracker.ceph.com/issues/71655
Signed-off-by: Sridhar Seshasayee <[email protected]>
…cheduler

Previously, sub-op reads returned a hardcoded cost of 0, bypassing
mClock's background bandwidth and tag calculation mechanisms. This
allowed backfill operations to proceed un-metered, occasionally causing
backend resource contention and driving up client tail latencies.

Cost is calculated based on whether the complete chunk/shard or a subchunk
needs to be read. The possible cases are:
1. Read the complete chunk aligned length:
   - Cost is set to the length of the chunk aligned extent size.
2. Fragmented reads:
   - Consider the subchunk length and count to calculate the cost.
   - compute_cost evaluates the exact layout of fragmented shard bytes on
     disk by summing up the active subchunk allocations exactly once
     (`fragmented_shard_bytes += k.second * subchunk_size`).
   - Linear Extent Scaling: Scale the baseline footprint cleanly by
     multiplying it against the true count of read extents (`tl.size()`),
     achieving a highly efficient O(N) time complexity.

This linear cost model is compatible with pools running with
'allow_ec_optimizations' set to true. Under the FastEC optimized
pipeline, most operations are unified and bypass fragment slicing,
meaning requests will primarily match the Case 1 chunk-aligned path.
In Case 2 where applicable, the O(N) loop ensures that cost will
scale proportionally according to the layout.

It is important to note that the amount of data to read was set to an upper
bound defined by osd_recovery_max_chunk (8 MiB) and was rounded up to the
stripe width. The reason for setting a higher than actual upper bound is that
there may be cases where the object doesn't have the xattrs yet to determine
its size. Therefore, the amount to read was ultimatly set to ~(8 MiB / k)
where k is the number of data shards. This can cause mClock to prolong
the recovery times as items stay longer in the queue. To address this, the
amount to read is set to the remaining length of the object to recover
if the object size is known. Otherwise, the amount to read is set to the
recovery chunk size as before. Therefore, in some cases, only the first
recovery read could be costly if the object context is not known.

The MOSDECSubOpRead class introduces the following:
 - cost member. This necessitates an increment to the HEAD_VERSION and
   appropriate handling within the encode and decode methods.
 - compute_cost() that is called when creating the message by
   ECCommonL::ReadPipeline::do_read_op(). This calls into ECSubRead::cost()
   that performs the actual calculations to set the cost based on the cases
   mentioned above.
 - The same sequence applies to the EC optimized path in
   ECCommon::ReadPipeline::do_read_op().

Fixes: https://tracker.ceph.com/issues/71655
Signed-off-by: Sridhar Seshasayee <[email protected]>
Add perf counters to show the status pertaining to the number of ops,
dynamic queue lengths, queue latency and bytes read for the following
ops handled in the high queues and in the scheduler queues:
 - peering
 - client
 - ec reads/writes
 - ec recovery reads

Additional counters can be added in the future based on the requirement.

Signed-off-by: Sridhar Seshasayee <[email protected]>
…tarvation

Adjust the 'background_best_effort' queue parameters across the
three standard mClock profiles (high_client_ops, balanced, and
high_recovery_ops) to ensure best effort ops are not starved.

Previously, the 'background_best_effort' queue carried a default allocation
of 0% (MIN) reservation and a weight of 1 under these profiles. When
concurrent client traffic is dense, the zero-reservation for example completely
starves backfill sub-ops (MSG_OSD_EC_READ) on pools with
'allow_ec_optimizations' set to false. This starvation forces the Primary OSD
to hold internal BlueStore transactions and PG object locks for extended
windows, causing severe client median (50th) latency inflation.

To prevent background starvation and resolve the effects of the primary lock
retention, the profile configurations are tuned as follows:

The following profile changes forces low-cost sub-ops to clear out of peer
queues rapidly to drop  primary locks, which helps improve the client
completion latency and tail latency (95th, 99th and 99.5th) percentile.

1. high_client_ops profile:
   - Grant 'background_best_effort' a safe 5% minimum reservation.
   - Scale the queue weight to 4.

2. balanced profile:
   - Grant 'background_best_effort' a 5% minimum reservation.
   - Set the queue weight to 2.

3. high_recovery_ops profile:
   - Grant 'background_best_effort' a 5% minimum reservation.
   - Set the queue weight to 2.

4. Modify the mClock config reference documentation to reflect the tuning
   changes to the best-effort QoS parameters across the profiles.

Note on Proportional Scaling Compatibility:
Configuring these changes shifts total reservations to 105% (e.g., 50%
client + 50% recovery + 5% best-effort under the Balanced profile). Under
heavy concurrent saturation, mClock's internal controls resolves this
gracefully via proportional down-scaling, preserving the underlying
device bandwidth limits for different classes of clients. For example instead
of the client being allocated 50% bandwidth, a slightly lower reservation is
allocated while shifting the remaining bandwidth to the best-effort queue.
This minor scaling shift is virtually unnoticeable to the client application,
but it prevents the internal queue deadlocks.

Signed-off-by: Sridhar Seshasayee <[email protected]>
…sters

Remove the warning that recommends using wpq scheduler as a fallback for EC
clusters. This issue is addressed by considering EC recovery reads as
background, assigning an accurate cost for those reads and tuning the QoS
parameters associated with best-effort class of operations.

Signed-off-by: Sridhar Seshasayee <[email protected]>
@sseshasa
sseshasa force-pushed the wip-fix-mclock-slow-ops-during-recovery branch from ed77fc2 to 2cf1e71 Compare June 12, 2026 06:59
@sseshasa
sseshasa merged commit 4541e95 into ceph:main Jun 12, 2026
12 checks passed
@sseshasa

sseshasa commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor Author

I have merged the PR to main based on my teuthology testing (see results here). While this bakes in main, the plan is test this on HDD based clusters and then backport it to the prior branches.

Results from testing on SSD based EC clusters is discussed above here.

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.

6 participants