Skip to content

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

Merged
batrick merged 5 commits into
ceph:tentaclefrom
sseshasa:wip-77377-tentacle
Jul 9, 2026
Merged

batrick merged 5 commits into
ceph:tentaclefrom
sseshasa:wip-77377-tentacle

Conversation

@sseshasa

@sseshasa sseshasa commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

backport tracker: https://tracker.ceph.com/issues/77377

backport of #64618
parent tracker: https://tracker.ceph.com/issues/71655

NOTE:
This is a manually created backport of #64618.
Please see the conflict section of the commits for exact details on why this had to be manually created.

In summary, the conflicts are due to a refactor of mClock code to src/common/mclock_common.h/cc which exists
from umbrella release only. The refactor to src/common was done to allow classic and crimson OSDs to use the
common mClock bits.

A subset of the commits were not backported due to the absence of mclock_common.h/cc and those commits are not relevant to the core functionality of the PR which is the following:

  1. Categorize recovery EC SubOp reads as background best-effort (was immediate) and assign an appropriate cost to each read operation for mClock. This fix alone will help address the slow op issue.
  2. Tune the existing mClock profiles to give a nominal reservation to background best-effort class of operations.   This fix improves the performance of background best-effort ops and in turn helps improve client latency.

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.

sseshasa added 2 commits June 26, 2026 22:34
Signed-off-by: Sridhar Seshasayee <[email protected]>
(cherry picked from commit 89c7b21)
Signed-off-by: Sridhar Seshasayee <[email protected]>
(cherry picked from commit 913e891)
@sseshasa
sseshasa requested review from a team as code owners June 26, 2026 19:19
@github-actions github-actions Bot added this to the tentacle milestone Jun 26, 2026
@sseshasa sseshasa modified the milestones: tentacle, v20.2.3 Jun 26, 2026
@sseshasa
sseshasa requested a review from rzarzynski June 26, 2026 19:20
github-actions[bot]

This comment was marked as outdated.

@github-actions github-actions Bot added the releng-audit-fail Release engineering: failed backport verification audit. label Jun 26, 2026
sseshasa and others added 3 commits June 29, 2026 16:01
…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]>
(cherry picked from commit a0464c3)

 Conflicts:
         src/osd/scheduler/OpSchedulerItem.h
- enum SchedulerClass doesn't exist in tentacle.Therefore, the original
  enum op_scheduler_class is used.

  enum SchedulerClass was introduced when mclock_common.h/cc was created
  as a refactor in later releases to share common bits between classic and
  crimson OSDs. Introduced in PR: ceph#63516.
…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]>
(cherry picked from commit e79befe)

Conflicts:
        src/osd/ECMsgTypes.h
- Removed a couple of variable declarations related to recovery of OMAP
  header and entries in EC pools which is yet to be backported to
  tentacle. See commit: a5f4a49.
… starvation

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]>
(cherry picked from commit 77421c8)

Conflicts:
        src/common/mclock_common.h
- src/common/mclock_common.h doesn't exist in tentacle.
  mclock_common.h/cc was created as a refactor in later releases to share
  common bits between classic and crimson OSDs. Introduced in PR:
  ceph#63516.

  Therefore, the profile parameters change is added to the original
  location in src/osd/mClockScheduler.cc.
@sseshasa

Copy link
Copy Markdown
Contributor Author

@rzarzynski @neha-ojha Please review this backport. I have only included the core commits that fix the issue. Other commits are excluded because tentacle doesn't have changes related to src/common/mclock_common.h/cc, which was introduced to keep common bits for both classic and crimson to use in umbrella. I have updated the conflict section of each commit with the necessary details.

I have tested the changes on a standalone cluster and can confirm that it looks fine. Teuthology tests should additionally help confirm that the changes are good.

Comment thread src/messages/MOSDECSubOpRead.h Resolved
Comment thread src/messages/MOSDECSubOpRead.h Resolved
Comment thread src/messages/MOSDECSubOpRead.h Resolved
@sseshasa sseshasa added the backport tentacle PRs that is a tentacle back-port label Jun 30, 2026
@yuriw

yuriw commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-yuri5-testing-20260630.203412-tentacle.

@mheler

mheler commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

I have reservations with this change going into the next tentacle release, especially given that it has had limited testing in main.

@sseshasa

sseshasa commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

I have reservations with this change going into the next tentacle release, especially given that it has had limited testing in main.

@mheler This will be merged only after our QE team gives feedback based on tests performed on a HDD based cluster. The teuthology tests are to confirm that there's no regression with this change and can be safely merged when QE feedback is received and assuming the fix works well. I have marked it as DNM until we get confirmation.

@sseshasa sseshasa added the DNM label Jul 8, 2026
@sseshasa

sseshasa commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

I have marked this PR as DNM until we get confirmation from QE that the fix works well on a larger cluster involving HDDs.

@batrick batrick removed the releng-audit-fail Release engineering: failed backport verification audit. label Jul 9, 2026
@github-actions github-actions Bot added the releng-audit-fail Release engineering: failed backport verification audit. label Jul 9, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated Backport Parity Review

Discrepancies detected between the backport PR and the original source PR(s). Please see the Commit Parity Visualizer below.


Automated Backport Parity Review - Backport Deviation Alert

A conflict or unapproved deviation was detected during the simulation of this backport. The code in this PR does not match a clean cherry-pick of the upstream commits.

Deviation in Backport a884378 (cherry-pick of a0464c3)

Affected File(s)

Range Diff

Click to expand
--- Original (a0464c3d)
+++ Backport (a8843786)
@@ -18,3 +18,13 @@
 
 Fixes: https://tracker.ceph.com/issues/71655
 Signed-off-by: Sridhar Seshasayee <[email protected]>
+(cherry picked from commit a0464c3d82825beddb5598b15a8752e567160a05)
+
+ Conflicts:
+         src/osd/scheduler/OpSchedulerItem.h
+- enum SchedulerClass doesn't exist in tentacle.Therefore, the original
+  enum op_scheduler_class is used.
+
+  enum SchedulerClass was introduced when mclock_common.h/cc was created
+  as a refactor in later releases to share common bits between classic and
+  crimson OSDs. Introduced in PR: https://github.com/ceph/ceph/pull/63516.

================================================================================
RANGE DIFF
================================================================================

1:  a0464c3d828 ! 1:  a8843786997 osd/scheduler: Classify EC subOp reads according to op priority for mClock
    @@ Commit message
     
         Fixes: https://tracker.ceph.com/issues/71655
         Signed-off-by: Sridhar Seshasayee <[email protected]>
    +    (cherry picked from commit a0464c3d82825beddb5598b15a8752e567160a05)
    +
    +     Conflicts:
    +             src/osd/scheduler/OpSchedulerItem.h
    +    - enum SchedulerClass doesn't exist in tentacle.Therefore, the original
    +      enum op_scheduler_class is used.
    +
    +      enum SchedulerClass was introduced when mclock_common.h/cc was created
    +      as a refactor in later releases to share common bits between classic and
    +      crimson OSDs. Introduced in PR: https://github.com/ceph/ceph/pull/63516.
     
      ## src/osd/scheduler/OpSchedulerItem.h ##
     @@ src/osd/scheduler/OpSchedulerItem.h: public:
    -     return op;
        }
      
    --   SchedulerClass get_scheduler_class() const final {
    +   op_scheduler_class get_scheduler_class() const final {
     -    auto type = op->get_req()->get_type();
     -    if (type == CEPH_MSG_OSD_OP ||
     -	type == CEPH_MSG_OSD_BACKOFF) {
    -+  SchedulerClass get_scheduler_class() const final {
     +    switch (op->get_req()->get_type()) {
     +    case CEPH_MSG_OSD_OP:
     +    case CEPH_MSG_OSD_BACKOFF:
    -       return SchedulerClass::client;
    +       return op_scheduler_class::client;
     -    } else {
     +    /**
     +     * EC SubOp reads for mClock are now classed based on their priority.
    @@ src/osd/scheduler/OpSchedulerItem.h: public:
     +      [[fallthrough]];
     +    }
     +    default:
    -       return SchedulerClass::immediate;
    +       return op_scheduler_class::immediate;
          }
        }

Deviation in Backport 5674234 (cherry-pick of e79befe)

Affected File(s)

Range Diff

Click to expand
--- Original (e79befea)
+++ Backport (56742348)
@@ -49,3 +49,10 @@
 
 Fixes: https://tracker.ceph.com/issues/71655
 Signed-off-by: Sridhar Seshasayee <[email protected]>
+(cherry picked from commit e79befea328e58366c43e490c129e2a467e6db84)
+
+Conflicts:
+        src/osd/ECMsgTypes.h
+- Removed a couple of variable declarations related to recovery of OMAP
+  header and entries in EC pools which is yet to be backported to
+  tentacle. See commit: a5f4a4902075e343df154da61e3d205d2bd2a5d5.

================================================================================
RANGE DIFF
================================================================================

1:  e79befea328 ! 1:  5674234892e src/messages, osd: Calculate and set cost for subOpReads for mClock scheduler
    @@ Commit message
     
         Fixes: https://tracker.ceph.com/issues/71655
         Signed-off-by: Sridhar Seshasayee <[email protected]>
    +    (cherry picked from commit e79befea328e58366c43e490c129e2a467e6db84)
    +
    +    Conflicts:
    +            src/osd/ECMsgTypes.h
    +    - Removed a couple of variable declarations related to recovery of OMAP
    +      header and entries in EC pools which is yet to be backported to
    +      tentacle. See commit: a5f4a4902075e343df154da61e3d205d2bd2a5d5.
     
      ## src/messages/MOSDECSubOpRead.h ##
     @@
    @@ src/osd/ECCommon.cc: void ECCommon::ReadPipeline::do_read_op(ReadOp &rop) {
     +    msg->compute_cost(cct, subchunk_info);
          m.push_back(std::make_pair(pg_shard.osd, msg));
          dout(10) << __func__ << ": will send msg " << *msg
    -              << " to osd." << pg_shard.osd << dendl;
    +              << " to osd." << pg_shard << dendl;
     
      ## src/osd/ECCommonL.cc ##
     @@ src/osd/ECCommonL.cc: void ECCommonL::ReadPipeline::do_read_op(ReadOp &op)
    @@ src/osd/ECMsgTypes.cc: void ECSubRead::decode(bufferlist::const_iterator &bl)
     
      ## src/osd/ECMsgTypes.h ##
     @@ src/osd/ECMsgTypes.h: struct ECSubRead {
    +   std::map<hobject_t, std::list<boost::tuple<uint64_t, uint64_t, uint32_t> >> to_read;
    +   std::set<hobject_t> attrs_to_read;
        std::map<hobject_t, std::vector<std::pair<int, int>>> subchunks;
    -   std::set<hobject_t> omap_headers_to_read;
    -   std::map<hobject_t, std::pair<std::string, uint64_t>> omap_read_from;
     +  /**
     +    * Calculate the cost of the SubOp read operation for mClock scheduler.
     +    *

Deviation in Backport d534b29 (cherry-pick of 77421c8)

Affected File(s)

Range Diff

Click to expand
--- Original (77421c83)
+++ Backport (d534b299)
@@ -1,4 +1,4 @@
-mclock_common: adjust mClock profile parameters to prevent backfill starvation
+mClockScheduler: adjust mClock profile parameters to prevent backfill starvation
 
 Adjust the 'background_best_effort' queue parameters across the
 three standard mClock profiles (high_client_ops, balanced, and
@@ -46,3 +46,14 @@
 but it prevents the internal queue deadlocks.
 
 Signed-off-by: Sridhar Seshasayee <[email protected]>
+(cherry picked from commit 77421c83665fdfd3343c487793e37e003d8c1891)
+
+Conflicts:
+        src/common/mclock_common.h
+- src/common/mclock_common.h doesn't exist in tentacle.
+  mclock_common.h/cc was created as a refactor in later releases to share
+  common bits between classic and crimson OSDs. Introduced in PR:
+  https://github.com/ceph/ceph/pull/63516.
+
+  Therefore, the profile parameters change is added to the original
+  location in src/osd/mClockScheduler.cc.

================================================================================
RANGE DIFF
================================================================================

1:  77421c83665 < -:  ----------- mclock_common: adjust mClock profile parameters to prevent backfill starvation
-:  ----------- > 1:  d534b299bee mClockScheduler: adjust mClock profile parameters to prevent backfill starvation

How to proceed:

  • Authors (Genuine Conflicts): If this is a genuine conflict requiring manual resolution, ensure your resolution is correct. You must explain the conflict resolution in the commit message (e.g., leave the standard Git Conflicts: block intact) and include an explanation for changes.
  • Authors (Need Help?): Reach out to the Component Lead for technical guidance on complex code conflicts.
  • Component Leads (Review): Please review the Range Diff(s) above to verify the author's manual conflict resolution is correct for this release branch. If the deviation is intentional, documented, and approved then the component lead or @ceph/ceph-release-manager can bypass this check by commenting /audit override.

Be familiar with the rules and guidelines for writing backports.


Commit Parity Visualizer

BACKPORT PR #69773 SOURCE PR SOURCE STATUS
ba8de83 osd/scheduler/mClockScheduler: Log the size of high priority queues. PR #64618 89c7b21 osd/scheduler/mClockScheduler: Log the size of high priority queues.
0df4486 osd/scheduler/mClockScheduler: Fix line alignments 913e891 osd/scheduler/mClockScheduler: Fix line alignments
a884378 osd/scheduler: Classify EC subOp reads according to op priority for mClock a0464c3 osd/scheduler: Classify EC subOp reads according to op priority for mClock
5674234 src/messages, osd: Calculate and set cost for subOpReads for mClock scheduler e79befe src/messages, osd: Calculate and set cost for subOpReads for mClock scheduler
d534b29 mClockScheduler: adjust mClock profile parameters to prevent backfill starvation 77421c8 mclock_common: adjust mClock profile parameters to prevent backfill starvation
<<<< MISSING IN BACKPORT >>>> 0b84dbe src/common/mclock_common: Fix output formatting of SchedulerClass
<<<< MISSING IN BACKPORT >>>> 5ae7768 mclock_common, mClockScheduler: Add perf counters for scheduler ops
<<<< MISSING IN BACKPORT >>>> 2cf1e71 doc/rados/configuration: Remove wpq recommendation warning for EC clusters

🛟 Need Help?

If you need technical help resolving these issues, please consult with the Component Lead. If you need administrative overrides, please see the #ceph-upstream-releases channel on Slack and request a review from the @ceph/ceph-release-manager.

📋 Component Lead / Release Manager

To override the audit failure, apply releng-audit-override label or comment /audit override.


⚠️ Note: Automated audit checks will be suspended on future pushes to prevent comment spam while you work.

When you are ready for a new audit, please remove the releng-audit-fail label or comment /audit retest.

CI Run Log: View Workflow Details

@github-actions github-actions Bot removed the releng-audit-fail Release engineering: failed backport verification audit. label Jul 9, 2026
@batrick
batrick merged commit e0b2a06 into ceph:tentacle Jul 9, 2026
11 of 13 checks passed
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.

5 participants