Skip to content

tools/cephfs_mirror: Distribute datasync threads evenly across snapshots - #67546

Merged
vshankar merged 4 commits into
ceph:mainfrom
kotreshhr:mirror-syncthreads-fair-scheduling
Apr 21, 2026
Merged

vshankar merged 4 commits into
ceph:mainfrom
kotreshhr:mirror-syncthreads-fair-scheduling

Conversation

@kotreshhr

@kotreshhr kotreshhr commented Feb 26, 2026 •

Copy link
Copy Markdown
Contributor

All datasync threads consume one snapshot at a time.
This starves the other queued snapshots for sync.
Provide an option to distribute the datasync threads
equally among queued snapshots.

Add the configuration cephfs_mirror_distribute_datasync_threads
to enable/disable data sync threads fair scheduling among
snapshots queued for syncing.

Fixes: https://tracker.ceph.com/issues/75091
Signed-off-by: Kotresh HR [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

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@github-actions

github-actions Bot commented Feb 26, 2026 •

Copy link
Copy Markdown

Config Diff Tool Output

+ added: cephfs_mirror_datasync_files_per_batch (cephfs-mirror.yaml.in)
+ added: cephfs_mirror_distribute_datasync_threads (cephfs-mirror.yaml.in)

The above configuration changes are found in the PR. Please update the relevant release documentation if necessary.
Ignore this comment if docs are already updated. To make the "Check ceph config changes" CI check pass, please comment /config check ok and re-run the test.

@kotreshhr

Copy link
Copy Markdown
Contributor Author

/config check ok

@kotreshhr

Copy link
Copy Markdown
Contributor Author

@vshankar please take look

@kotreshhr

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@kotreshhr

Copy link
Copy Markdown
Contributor Author

/config check ok

Copilot AI 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.

Pull request overview

This PR improves CephFS mirroring’s datasync scheduling so that (optionally) datasync worker threads are shared more evenly across multiple queued snapshot syncs, reducing starvation when one large snapshot dominates the queue.

Changes:

  • Add configurable “fair scheduling” for datasync threads across queued snapshots (cephfs_mirror_distribute_datasync_threads).
  • Add a batching knob to control how many files a datasync thread processes per scheduling cycle (cephfs_mirror_datasync_files_per_batch).
  • Add QA coverage for starvation vs non-starvation behavior and document the new configuration options.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/tools/cephfs_mirror/PeerReplayer.h Adds helpers/state for fair scheduling and batching configuration.
src/tools/cephfs_mirror/PeerReplayer.cc Implements fair-share limiting in has_pending_work(), batching in datasync loop, and config refresh helper.
src/common/options/cephfs-mirror.yaml.in Introduces new cephfs-mirror configuration options and their descriptions/defaults.
qa/tasks/cephfs/test_mirroring.py Adds integration tests validating starvation behavior with the option toggled.
doc/cephfs/cephfs-mirroring.rst Exposes the new options in the mirroring documentation via confval entries.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/tools/cephfs_mirror/PeerReplayer.cc Resolved
Comment thread src/tools/cephfs_mirror/PeerReplayer.cc Resolved
Comment thread src/tools/cephfs_mirror/PeerReplayer.h Resolved
Comment thread qa/tasks/cephfs/test_mirroring.py Resolved
Comment thread qa/tasks/cephfs/test_mirroring.py Resolved
Comment thread src/tools/cephfs_mirror/PeerReplayer.cc Resolved
Comment thread src/tools/cephfs_mirror/PeerReplayer.cc Resolved
All datasync threads consume one snapshot at a time.
This starves the other queued snapshots for sync.
Provide an option to distribute the datasync threads
equally among queued snapshots.

Add the configuration cephfs_mirror_distribute_datasync_threads
to enable/disable data sync threads fair scheduling among
snapshots queued for syncing.

Fixes: https://tracker.ceph.com/issues/75091
Signed-off-by: Kotresh HR <[email protected]>
@kotreshhr
kotreshhr force-pushed the mirror-syncthreads-fair-scheduling branch from d9ba79a to 27f2b4f Compare March 5, 2026 10:04
@kotreshhr
kotreshhr requested a review from a team as a code owner March 5, 2026 10:04
Introduces file batching for datasync threads, it's the maximum
number of files that a datasync thread processes per scheduling
cycle before yielding.

The number of files per batch can be configured using the config
'cephfs_mirror_datasync_files_per_batch'. The default is set
to 64

Fixes: https://tracker.ceph.com/issues/75091
Signed-off-by: Kotresh HR <[email protected]>
@kotreshhr
kotreshhr force-pushed the mirror-syncthreads-fair-scheduling branch from 27f2b4f to fcf99b3 Compare March 6, 2026 07:23
@kotreshhr

Copy link
Copy Markdown
Contributor Author

@kotreshhr

Copy link
Copy Markdown
Contributor Author

Teuthology Run - https://pulpito.ceph.com/khiremat-2026-03-06_09:00:51-fs-wip-khiremat-multithread-mirror-fair-sched-67546-1-distro-default-trial/

Following test case added for starvation is failed

2026-03-06T10:40:24.485 INFO:tasks.cephfs_test_runner:======================================================================
2026-03-06T10:40:24.485 INFO:tasks.cephfs_test_runner:FAIL: test_cephfs_mirror_multithread_snapshot_starvation (tasks.cephfs.test_mirroring.TestMirroring.test_cephfs_mirror_multithread_snapshot_starvation)
2026-03-06T10:40:24.485 INFO:tasks.cephfs_test_runner:Test that newly added mirrored directories are starved until the current syncing one is completed.
2026-03-06T10:40:24.485 INFO:tasks.cephfs_test_runner:----------------------------------------------------------------------
2026-03-06T10:40:24.485 INFO:tasks.cephfs_test_runner:Traceback (most recent call last):
2026-03-06T10:40:24.486 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/git.ceph.com_ceph-c_fcf99b3fdf891a24bbc6ccf53aee44767c369784/qa/tasks/cephfs/test_mirroring.py", line 1707, in test_cephfs_mirror_multithread_snapshot_starvation
2026-03-06T10:40:24.486 INFO:tasks.cephfs_test_runner:    self.assertGreater(d1_sync_time_stamp, d0_sync_time_stamp)
2026-03-06T10:40:24.486 INFO:tasks.cephfs_test_runner:AssertionError: 1923.768759 not greater than 1923.768759

Cause:
The directories, d0 : 5k files, d1: 10 files, d2: 10 files, The time taken to sync 10 files is mostly less than 1 second = 0 seconds. So even though d1 and d2 is picked after d0 is synced completely, the last_sync_time_stamp of d0 and d1 is same. Hence the assertion has failed. Need to adjust the test to verify starvation in a better way.

@kotreshhr
kotreshhr force-pushed the mirror-syncthreads-fair-scheduling branch from fcf99b3 to 5e58b26 Compare March 6, 2026 11:58
@kotreshhr

kotreshhr commented Mar 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Teuthology Run - https://pulpito.ceph.com/khiremat-2026-03-06_09:00:51-fs-wip-khiremat-multithread-mirror-fair-sched-67546-1-distro-default-trial/

Following test case added for starvation is failed

2026-03-06T10:40:24.485 INFO:tasks.cephfs_test_runner:======================================================================
2026-03-06T10:40:24.485 INFO:tasks.cephfs_test_runner:FAIL: test_cephfs_mirror_multithread_snapshot_starvation (tasks.cephfs.test_mirroring.TestMirroring.test_cephfs_mirror_multithread_snapshot_starvation)
2026-03-06T10:40:24.485 INFO:tasks.cephfs_test_runner:Test that newly added mirrored directories are starved until the current syncing one is completed.
2026-03-06T10:40:24.485 INFO:tasks.cephfs_test_runner:----------------------------------------------------------------------
2026-03-06T10:40:24.485 INFO:tasks.cephfs_test_runner:Traceback (most recent call last):
2026-03-06T10:40:24.486 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/git.ceph.com_ceph-c_fcf99b3fdf891a24bbc6ccf53aee44767c369784/qa/tasks/cephfs/test_mirroring.py", line 1707, in test_cephfs_mirror_multithread_snapshot_starvation
2026-03-06T10:40:24.486 INFO:tasks.cephfs_test_runner:    self.assertGreater(d1_sync_time_stamp, d0_sync_time_stamp)
2026-03-06T10:40:24.486 INFO:tasks.cephfs_test_runner:AssertionError: 1923.768759 not greater than 1923.768759

Cause: The directories, d0 : 5k files, d1: 10 files, d2: 10 files, The time taken to sync 10 files is mostly less than 1 second = 0 seconds. So even though d1 and d2 is picked after d0 is synced completely, the last_sync_time_stamp of d0 and d1 is same. Hence the assertion has failed. Need to adjust the test to verify starvation in a better way.

Fixed this by increasing files count as below:

d0 : 10k files
d1 : 100 files
d2 : 100 files

New teuthology run - https://pulpito.ceph.com/khiremat-2026-03-06_12:06:29-fs-wip-khiremat-multithread-mirror-fair-sched-67546-1-distro-default-trial/

@kotreshhr

Copy link
Copy Markdown
Contributor Author

Teuthology Run - https://pulpito.ceph.com/khiremat-2026-03-06_09:00:51-fs-wip-khiremat-multithread-mirror-fair-sched-67546-1-distro-default-trial/

Following test case added for starvation is failed

2026-03-06T10:40:24.485 INFO:tasks.cephfs_test_runner:======================================================================
2026-03-06T10:40:24.485 INFO:tasks.cephfs_test_runner:FAIL: test_cephfs_mirror_multithread_snapshot_starvation (tasks.cephfs.test_mirroring.TestMirroring.test_cephfs_mirror_multithread_snapshot_starvation)
2026-03-06T10:40:24.485 INFO:tasks.cephfs_test_runner:Test that newly added mirrored directories are starved until the current syncing one is completed.
2026-03-06T10:40:24.485 INFO:tasks.cephfs_test_runner:----------------------------------------------------------------------
2026-03-06T10:40:24.485 INFO:tasks.cephfs_test_runner:Traceback (most recent call last):
2026-03-06T10:40:24.486 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/git.ceph.com_ceph-c_fcf99b3fdf891a24bbc6ccf53aee44767c369784/qa/tasks/cephfs/test_mirroring.py", line 1707, in test_cephfs_mirror_multithread_snapshot_starvation
2026-03-06T10:40:24.486 INFO:tasks.cephfs_test_runner:    self.assertGreater(d1_sync_time_stamp, d0_sync_time_stamp)
2026-03-06T10:40:24.486 INFO:tasks.cephfs_test_runner:AssertionError: 1923.768759 not greater than 1923.768759

Cause: The directories, d0 : 5k files, d1: 10 files, d2: 10 files, The time taken to sync 10 files is mostly less than 1 second = 0 seconds. So even though d1 and d2 is picked after d0 is synced completely, the last_sync_time_stamp of d0 and d1 is same. Hence the assertion has failed. Need to adjust the test to verify starvation in a better way.

Fixed this by increasing files count as below:

d0 : 10k files
d1 : 100 files
d2 : 100 files

New teuthology run - https://pulpito.ceph.com/khiremat-2026-03-06_12:06:29-fs-wip-khiremat-multithread-mirror-fair-sched-67546-1-distro-default-trial/

Runs are successful:

:/teuthology/khiremat-2026-03-06_12:06:29-fs-wip-khiremat-multithread-mirror-fair-sched-67546-1-distro-default-trial/90794$ find . | grep teuthology.log | xargs grep "\.\.\. ok$"  | grep test_runner   | grep starved
2026-03-06T12:44:21.529 INFO:tasks.cephfs_test_runner:Test that newly added mirrored directories are not starved until the current syncing one is completed. ... ok
2026-03-06T12:47:33.462 INFO:tasks.cephfs_test_runner:Test that newly added mirrored directories are starved until the current syncing one is completed. ... ok

khiremat@trial200:/teuthology/khiremat-2026-03-06_12:06:29-fs-wip-khiremat-multithread-mirror-fair-sched-67546-1-distro-default-trial/90796$ find . | grep teuthology.log | xargs grep "\.\.\. ok$"  | grep test_runner   | grep starved
2026-03-06T12:47:45.954 INFO:tasks.cephfs_test_runner:Test that newly added mirrored directories are not starved until the current syncing one is completed. ... ok
2026-03-06T12:51:09.057 INFO:tasks.cephfs_test_runner:Test that newly added mirrored directories are starved until the current syncing one is completed. ... ok

@vshankar

Copy link
Copy Markdown
Contributor

vshankar added a commit to vshankar/ceph that referenced this pull request Mar 24, 2026
@kotreshhr kotreshhr mentioned this pull request Apr 6, 2026
4 of 14 tasks
Comment thread src/tools/cephfs_mirror/PeerReplayer.cc Resolved
vshankar added a commit to vshankar/ceph that referenced this pull request Apr 20, 2026
* refs/pull/67546/head:
	doc: Document cephfs multithread mirror configs
	qa: Validate datasync thread fair scheduling
	tools/cephfs-mirror: Introduce file batching for datasync threads
	tools/cephfs_mirror: Distribute datasync threads across snapshots

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

@vshankar
vshankar merged commit 2016787 into ceph:main Apr 21, 2026
6 checks passed
@github-actions

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/24716607520

@kotreshhr kotreshhr mentioned this pull request Apr 29, 2026
4 of 14 tasks
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.

4 participants