Skip to content

crimson: Support mclock for crimson - #62002

Merged
Matan-B merged 7 commits into
ceph:mainfrom
mohit84:crimson_mclock_1
Dec 8, 2025
Merged

Matan-B merged 7 commits into
ceph:mainfrom
mohit84:crimson_mclock_1

Conversation

@mohit84

@mohit84 mohit84 commented Feb 26, 2025

Copy link
Copy Markdown
Contributor

The patch is trying to sync mclock source of crimson similar to classic osds. Currently the feature is use by crimson only for background recovery operations but later we will use it for other OSD operations also.To use the same user need to configure crimson_osd_scheduler_concurrency parameter for osd and the schedule is enabled for the recovery related operations.

Fixes: #https://tracker.ceph.com/issues/67367

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
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

@mohit84
mohit84 requested a review from a team as a code owner February 26, 2025 09:37
@mohit84
mohit84 marked this pull request as draft February 26, 2025 09:37
@mohit84
mohit84 requested review from Matan-B and sseshasa February 26, 2025 09:37
@Matan-B
Matan-B requested a review from jdurgin February 26, 2025 11:15

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

Note: This PR depends on #61647.


Continuing our offline discussion regarding radosbench perf degradation with the changes here. I couldn't spot anything related. The only scheduler user still seems to be BackgroundRecoveryT<T>::start(). I'd suggest retrying with clean main to see if the issue persists there.

I haven't reviewed the overall structure yet but it looks promising! We would probably want to throttle future users/operations with a more generalized way, perhaps by using the PhasedOperationT mechanism.


Followup discussion: We should try to get #61647 merged first.

Comment thread src/crimson/osd/pg.h Outdated
Comment on lines +870 to +886
int64_t pri = 0;
get_pgpool().info.opts.get(pool_opts_t::RECOVERY_OP_PRIORITY, &pri);
return pri > 0 ? pri : crimson::common::local_conf()->osd_recovery_op_priority;
const std::string _type = this->shard_services.get_cct()->_conf.get_val<std::string>("osd_op_queue");
const std::string *type = &_type;
if (*type == "mclock_scheduler") {
if (peering_state.is_forced_recovery_or_backfill()) {
return peering_state.recovery_msg_priority_t::FORCED;
} else if (peering_state.is_undersized()) {
return peering_state.recovery_msg_priority_t::UNDERSIZED;
} else if (peering_state.is_degraded()) {
return peering_state.recovery_msg_priority_t::DEGRADED;
} else {
return peering_state.recovery_msg_priority_t::BEST_EFFORT;
}
} else {
int64_t pri = 0;
get_pgpool().info.opts.get(pool_opts_t::RECOVERY_OP_PRIORITY, &pri);
return pri > 0 ? pri : crimson::common::local_conf()->osd_recovery_op_priority;
}

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.

Let's reuse PeeringState::get_recovery_op_priority here.
Conf usage at the end be differed with IFDEF.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@Matan-B
Matan-B requested a review from amathuria February 26, 2025 11:34
@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

Comment thread src/crimson/common/config_proxy.h Outdated
int get_val(std::string_view key, std::string *val) const {
return get_config().get_val(*values, key, val);
}

void set_val_default_sync(const std::string& key, const std::string& val) {

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.

this is inconsistent with set_val() - observers are not notified of changes made here. how are other cores updated when only shard 0 sets these defaults?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Need to think about it, during mclock_scheduler it will set on all the shards the issue is during handle_conf_change.

Comment thread src/crimson/osd/osd.cc Outdated
@@ -683,6 +689,24 @@ seastar::future<> OSD::_send_boot()
m->metadata["osd_type"] = "crimson";
return monc->send_message(std::move(m));
}
seastar::future<bool> OSD::_get_device_type()
{
LOG_PREFIX(OSD::_get_device_type);

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.

this is repeating what _add_device_class does, you can give it a return value or make is_rotational a member of OSD instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread src/crimson/osd/osd_operation.cc Outdated
update_from_config(conf);
}

void OperationThrottler::wake()
{
WorkItem work_item;
int i = 0;

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.

unused variable?

Comment thread src/crimson/osd/osd_operation.cc Outdated
if (wait_duration.count() > 0) {
logger().info("No items ready. Retrying wake() in {} ms", wait_duration.count());
seastar::sleep(wait_duration).then([this] {
wake();

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.

instead of recursion, why not continue in the while loop and add the condition that work_item is non-null, like the structure in classic?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done


#define dout_context cct
#define dout_subsys ceph_subsys_osd

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.

there's a lot of duplication from classic in this file - is it worth abstracting out key differences so the large common pieces can be shared? e.g. default profiles and config information?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@Matan-B Matan-B added this to Crimson Mar 4, 2025
@Matan-B Matan-B moved this to In Progress in Crimson Mar 4, 2025
@github-actions

github-actions Bot commented May 3, 2025

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 May 3, 2025
@mohit84

mohit84 commented May 6, 2025

Copy link
Copy Markdown
Contributor Author

I am working on the same and will refresh a patch after resolve the comments.

@github-actions github-actions Bot removed the stale label May 6, 2025
@mohit84

mohit84 commented May 27, 2025

Copy link
Copy Markdown
Contributor Author

Push a patch(#63516) to refactor mclock source code , after backport the same i will refresh the code here.

@mohit84
mohit84 force-pushed the crimson_mclock_1 branch from c63c8b0 to 51a3ffc Compare July 21, 2025 05:36
@mohit84 mohit84 moved this from In Progress to Awaits review in Crimson Jul 21, 2025
@mohit84
mohit84 marked this pull request as ready for review July 21, 2025 05:39
@mohit84

mohit84 commented Jul 21, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@mohit84

mohit84 commented Jul 21, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@mohit84

mohit84 commented Jul 21, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

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

The PR involves changes of common code, introduction of osd member methods, renaming of existing classes and new logic (such as wake_set).
Can you please separate the PR into commits and explain the relevant changes in the commit message? It makes it harder to review otherwise.

Comment thread src/common/mclock_common.cc Outdated
Comment on lines +259 to +263
#ifdef WITH_CRIMSON
auto set_config = [&conf = cct->_conf](const char *key, auto val) {
return conf.set_val_default_sync(key, std::to_string(val));
};
#else

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.

The same logic applies to Crimson and non-Crimson targets, can we instead introduce a Crimson set_val_default and avoid this ifdef?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread src/common/mclock_common.cc Resolved
Comment thread src/common/mclock_common.cc Outdated
@@ -477,6 +484,7 @@ void MclockConfig::mclock_handle_conf_change(const ConfigProxy& conf,
// profile defaults by making one of the OSD shards remove the key from
// config monitor store. Note: monc is included in the check since the
// mock unit test currently doesn't initialize it.
#ifndef WITH_CRIMSON

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.

Can you please explain why is it not needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread src/common/mclock_common.cc Outdated
}
// Alternatively, the QoS parameter, if set ephemerally for this OSD via
// the 'daemon' or 'tell' interfaces must be removed.
#ifndef WITH_CRIMSON

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.

ditto

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

After delete a key from in memory the key is automatically reset so we don;t need to run apply_changes. In crimson we don;t have any API yet but it is not required even in case of classic also i think it is not required.

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.

apply_changes is called each time we change config option to notify the observers and in return call the observer's handle_conf_change. For crimson I think we should probably only skip the "apply_changes" line due to the way rm_val is implemented in Crimson.

Comment thread src/crimson/osd/osd.cc Outdated
@@ -581,6 +581,14 @@ seastar::future<> OSD::start()
return _add_me_to_crush();
}).then([this] {
return _add_device_class();
}).then([this] {
if (is_rotational) {

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.

The above would be true even if is_rotational is false since is_rotational is optional.
Did you mean to check here if it has value or if the value is true?

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.

In either way, can you please explain the intent here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will update in next patch specific to crimson related patch.

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.

will update in next patch specific to crimson related patch.

Was this addressed?

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.

The above would be true even if is_rotational is false since is_rotational is optional. Did you mean to check here if it has value or if the value is true?

This wasn't addressed.

Comment thread src/crimson/osd/osd.h Outdated
@@ -190,6 +191,7 @@ class OSD final : public crimson::net::Dispatcher,
seastar::future<> _send_boot();
seastar::future<> _add_me_to_crush();
seastar::future<> _add_device_class();
//#seastar::future<bool> _get_device_type();

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.

nit: Do we still need this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No

@mohit84

mohit84 commented Nov 12, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@mohit84

mohit84 commented Nov 12, 2025

Copy link
Copy Markdown
Contributor Author

Commit named "initialize mClock scheduler and detect rotational devices" adds the main logic for the new OperationThrottler but has no description in the commit message.

done

@mohit84

mohit84 commented Nov 12, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

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

Great work, PR is much easier to review! Left final question regarding OperationThrottler::background_task otherwise looks ok.

if (auto when_ready = std::get_if<double>(&work_item)) {
ceph::real_clock::time_point future_time = ceph::real_clock::from_double(*when_ready);
auto now = ceph::real_clock::now();
auto wait_duration = std::chrono::duration_cast<std::chrono::milliseconds>(future_time - now);

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.

Not sure that this was addressed, we don't check that future_time is later than now and instead unconditionally cast it.. Is this behavior defined?

Comment thread src/crimson/osd/osd_operation.cc Outdated
auto wait_duration = std::chrono::duration_cast<std::chrono::milliseconds>(future_time - now);
if (wait_duration.count() > 0) {
INFO("No items ready. Retrying wake() in {} ms", wait_duration.count());
co_await seastar::sleep(wait_duration);

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.

See line 190, scheduler->dequeue() is called, later on sleep is called and then continue moved to the next iteration.

The application has to reattempt to dequeue an item

Wasn't the item already dequeued?

@mohit84

mohit84 commented Nov 18, 2025

Copy link
Copy Markdown
Contributor Author

Great work, PR is much easier to review! Left final question regarding OperationThrottler::background_task otherwise looks ok.

AFAIK the future time will be greater than current time even if somehow it is possible it is lower than current time there is no issue. If mclock scheduler is returning floating value after dequeue it means the scheduler has not dequeued an item,the original item is still in the queue.

@mohit84

mohit84 commented Nov 19, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

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

@mohit84, Can you please run this through the suite? Seems that osd_op_queue is using mclock by default so this should be sufficient for testing.

@Matan-B Matan-B moved this from In Progress to Needs QA in Crimson Nov 19, 2025
…onal devices, and run OperationThrottler background task

Initialize the mClock scheduler on all shards when the device class
is non-rotational. If the device is rotational throw an exception
to prevent unsupported configurations.

In addition, introduce a background task in OperationThrottler that
continuously dequeues and schedules client requests from the mClock
scheduler based on available credits and throttling limits.

Signed-off-by: Mohit Agrawal <[email protected]>
…roduce get_average_object_size for pg

1)  Replace usage of crimson::osd::scheduler::scheduler_class_t
    with unified SchedulerClass
2) Add priority to scheduler params structure
3) Introduce get_average_object_size for pg

Signed-off-by: Mohit Agrawal <[email protected]>
The patch is trying to sync mclock source of crimson similar to
classic osds. Currently the feature is use by crimson only for
background recovery operations but later we will use it for other
OSD operations also.To use the same user need to configure
crimson_osd_scheduler_concurrency parameter for osd.

Replace item_t with WorkItem variant to maintain similarity
with classic OSD.

Introduce cost and priority as part of item_t.

Fixes: https://tracker.ceph.com/issues/67367
Signed-off-by: Mohit Agrawal <[email protected]>
@mohit84

mohit84 commented Dec 4, 2025

Copy link
Copy Markdown
Contributor Author

@mohit84, Can you please run this through the suite? Seems that osd_op_queue is using mclock by default so this should be sufficient for testing.

The result is available at https://pulpito.ceph.com/moagrawa-2025-12-03_14:03:13-crimson-rados-main-distro-crimson-debug-smithi/ and details of failed job are also mentioned at https://tracker.ceph.com/projects/crimson/wiki/MAIN

@Matan-B

Matan-B commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

The result is available at https://pulpito.ceph.com/moagrawa-2025-12-03_14:03:13-crimson-rados-main-distro-crimson-debug-smithi/ and details of failed job are also mentioned at https://tracker.ceph.com/projects/crimson/wiki/MAIN

Thank you for the summary!

The test run looks reasonable to me. However, since there are ~5 failures with new trackers I think we should try to further analyze the failures. Especially https://tracker.ceph.com/issues/74084 and https://tracker.ceph.com/issues/74086.
This PR is likely to be ok to merge but the trackers submitted should provide more information so we can have more certainty.

With the two above trackers providing more information, we would be ok to merge. Even if one of them is somewhat related to this PR - I'm ok with merging so that this PR won't need any more rebasing and the issue could be addressed after merge.

Please let me know if I can help with analyzing the trackers.

@mohit84

mohit84 commented Dec 5, 2025

Copy link
Copy Markdown
Contributor Author

The result is available at https://pulpito.ceph.com/moagrawa-2025-12-03_14:03:13-crimson-rados-main-distro-crimson-debug-smithi/ and details of failed job are also mentioned at https://tracker.ceph.com/projects/crimson/wiki/MAIN

Thank you for the summary!

The test run looks reasonable to me. However, since there are ~5 failures with new trackers I think we should try to further analyze the failures. Especially https://tracker.ceph.com/issues/74084 and https://tracker.ceph.com/issues/74086. This PR is likely to be ok to merge but the trackers submitted should provide more information so we can have more certainty.

With the two above trackers providing more information, we would be ok to merge. Even if one of them is somewhat related to this PR - I'm ok with merging so that this PR won't need any more rebasing and the issue could be addressed after merge.

Please let me know if I can help with analyzing the trackers.

Sure, though i believe the failure is not related to the PR but we can wait. I will work to resolve the same then we can merge the PR.

@Matan-B

Matan-B commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

Sure, though i believe the failure is not related to the PR but we can wait. I will work to resolve the same then we can merge the PR.

I've retested the PR https://tracker.ceph.com/projects/crimson/wiki/MAIN#httpspulpitocephcommatan-2025-12-07_112602-crimson-rados-wip-moagrawa-crimson-mclock-debug-distro-crimson-debug-smithi - Merging.

@Matan-B
Matan-B merged commit a07fc92 into ceph:main Dec 8, 2025
@Matan-B Matan-B moved this from Needs QA to Merged (Main) in Crimson Dec 8, 2025
@github-actions

github-actions Bot commented Dec 8, 2025

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I have resolved the following tracker ticket due to the merge of this PR:

No backports are pending for the ticket. If this is incorrect, please update the tracker
ticket and reset to Pending Backport state.

Update Log: https://github.com/ceph/ceph/actions/runs/20023533240

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Merged (Pre Umbrella cutoff)

Development

Successfully merging this pull request may close these issues.

6 participants