Skip to content

mclock : Refactor the mClock scheduler source code - #63516

Merged
SrinivasaBharath merged 2 commits into
ceph:mainfrom
mohit84:refactor_mclock
Jun 20, 2025
Merged

SrinivasaBharath merged 2 commits into
ceph:mainfrom
mohit84:refactor_mclock

Conversation

@mohit84

@mohit84 mohit84 commented May 27, 2025 •

Copy link
Copy Markdown
Contributor

Refactor the mClock scheduler source code into a common module so that both Classic and Crimson OSDs can use it.

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

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

@mohit84
mohit84 requested a review from a team as a code owner May 27, 2025 06:25
@mohit84
mohit84 requested review from athanatos and sseshasa May 27, 2025 06:25
@mohit84

mohit84 commented May 27, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@mohit84 mohit84 mentioned this pull request May 27, 2025
14 tasks

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

Seems reasonable

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

Mostly looks good to me other than a couple of queries, some minor nits around line lengths and trailing whitespaces.

Comment thread src/common/mclock_common.cc Resolved
Comment thread src/common/mclock_common.cc Resolved
Comment thread src/common/mclock_common.h Resolved
Comment thread src/common/mclock_common.h Resolved
Comment thread src/common/mclock_common.cc Resolved
Comment thread src/common/mclock_common.cc Resolved
Comment thread src/common/mclock_common.cc Resolved
Comment thread src/common/mclock_common.h Resolved
Comment thread src/osd/scheduler/mClockScheduler.h Resolved
Comment thread src/common/mclock_common.h Resolved
@mohit84
mohit84 force-pushed the refactor_mclock branch from d476e99 to 07e37c0 Compare May 28, 2025 10:29
@mohit84

mohit84 commented May 28, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@mohit84
mohit84 force-pushed the refactor_mclock branch from 07e37c0 to 1c74cc6 Compare May 28, 2025 11:34
@mohit84

mohit84 commented May 28, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

Comment thread src/common/mclock_common.h Resolved
Comment thread src/common/mclock_common.h Resolved
@mohit84
mohit84 force-pushed the refactor_mclock branch from 1c74cc6 to 10101d4 Compare May 28, 2025 12:50
@mohit84

mohit84 commented May 28, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

Comment thread src/common/mclock_common.cc Resolved
Comment thread src/common/mclock_common.h Resolved
Comment thread src/osd/scheduler/mClockScheduler.cc Resolved
Comment thread src/osd/scheduler/mClockScheduler.cc Resolved
Comment thread src/osd/scheduler/mClockScheduler.h Resolved
@mohit84
mohit84 force-pushed the refactor_mclock branch from 10101d4 to 5450c18 Compare May 29, 2025 05:37
@mohit84

mohit84 commented May 29, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@mohit84

mohit84 commented May 29, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

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

Changes LGTM. Let's get this through testing.

@mohit84

mohit84 commented Jun 9, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

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.

Looks like the new call (std::invoke_result) uses a different syntax. Can you check and fix the same?

mohit84 added 2 commits June 9, 2025 17:20
Refactor the mClock scheduler source code into a common module
so that both Classic and Crimson OSDs can use it.

Fixes: https://tracker.ceph.com/issues/71445
Signed-off-by: Mohit Agrawal <[email protected]>
@mohit84
mohit84 force-pushed the refactor_mclock branch from d8ff017 to a1f6173 Compare June 9, 2025 12:00
@mohit84

mohit84 commented Jun 9, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@mohit84

mohit84 commented Jun 10, 2025

Copy link
Copy Markdown
Contributor Author

@athanatos Can you please review this a1f6173 , the change is in dmclock code path.

@sseshasa

Copy link
Copy Markdown
Contributor

jenkins test api

@sseshasa

Copy link
Copy Markdown
Contributor

jenkins test make check arm64

@ljflores

Copy link
Copy Markdown
Member

jenkins test api

@sseshasa

Copy link
Copy Markdown
Contributor

@SrinivasaBharath
SrinivasaBharath merged commit 1381a89 into ceph:main Jun 20, 2025
sseshasa added a commit to sseshasa/ceph that referenced this pull request Jun 29, 2026
…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.
sseshasa added a commit to sseshasa/ceph that referenced this pull request Jun 29, 2026
… 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 added a commit to sseshasa/ceph that referenced this pull request Jun 29, 2026
… 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 doesn't exist in squid.
  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 added a commit to sseshasa/ceph that referenced this pull request Jul 14, 2026
… 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 doesn't exist in squid.
  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.
mertsunacoglu pushed a commit to mertsunacoglu/ceph that referenced this pull request Aug 26, 2026
…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.
mertsunacoglu pushed a commit to mertsunacoglu/ceph that referenced this pull request Aug 26, 2026
… 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.
batrick pushed a commit that referenced this pull request Oct 20, 2026
…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 squid. 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: #63516.
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