Skip to content

rgw/lc: optimize lifecycle processing for multiple rules - #66367

Merged
ivancich merged 3 commits into
ceph:mainfrom
mheler:lc-tag-scan-reduction
Feb 3, 2026
Merged

ivancich merged 3 commits into
ceph:mainfrom
mheler:lc-tag-scan-reduction

Conversation

@mheler

@mheler mheler commented Nov 21, 2025 •

Copy link
Copy Markdown
Contributor

rgw/lc: optimize lifecycle processing for multiple rules

This PR improves lifecycle policy processing performance when multiple rules are configured on a bucket.

Summary:

Three optimizations that work together to reduce I/O and improve concurrency:

  1. Group rules by prefix - Process rules with the same prefix in a single bucket listing instead of rescanning for each rule
  2. Spawn per object instead of per rule - Change from spawning N×M coroutines (N objects × M rules) to N coroutines, improving workpool utilization and concurrency.
  3. Cache object tags - Prefetch tags once per object and reuse across all tag-based rules, reducing redundant RADOS getxattr calls

Prior to these changes on a bucket with 100K object (4MB in size) evenly distributed with 32 tags, and using a 32 rule lifecycle policy expiring per each tag we observed the following times:

real 32m23.334s
user 5m6.625s
sys	6m47.315s

After this PR, the time to run the lifecycle policy was significantly cut back and aligns more closely with baseline results of ~3m (3m8.733s) using a single rule lifecycle policy

real 3m36.347s
user 0m43.528s
sys	0m29.191s

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

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)
    • [X ] 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.

@mheler
mheler requested a review from a team as a code owner November 21, 2025 19:10
@github-actions github-actions Bot added the rgw label Nov 21, 2025
@mheler
mheler force-pushed the lc-tag-scan-reduction branch from cf876eb to 720187a Compare November 21, 2025 19:13
@mheler
mheler force-pushed the lc-tag-scan-reduction branch from 720187a to 3c07dfe Compare November 24, 2025 18:14
Comment thread src/rgw/rgw_lc.cc Resolved
Group lifecycle rules by prefix and process them in one bucket listing,
filtering invalid or zone-incompatible rules before scanning so we avoid
rescanning the bucket for each rule.

Signed-off-by: Matthew N. Heler <[email protected]>
Currently, bucket_lc_process() spawns one coroutine per rule per
object. This means for a bucket with N lifecycle rules, we spawn
N coroutines for each object.

This creates a workpool utilization problem when there are many
rules. With the default rgw_lc_max_wp_worker=128 and 64 rules,
only ~2 objects can be processed concurrently (128 / 64 ≈ 2).
This severely limits parallelism and causes performance degradation
when multiple tag-based or other rules are configured.

This commit changes the concurrency model to spawn one coroutine
per object instead. Each coroutine processes all applicable rules
for that object sequentially. This allows the full workpool of 128
coroutines to process 128 objects concurrently, regardless of the
number of rules.

Additionally, this fixes a timing issue where rule.update() was
called inside the async coroutine, potentially reading stale data
from the shared LCObjsLister after it had advanced. Now all rules
are updated before spawning to capture the correct lister state.

Signed-off-by: Matthew N. Heler <[email protected]>
Prefetch tags once per object and pass them into LCOpRule, letting
the tag filter reuse the cached set and skip tag-based rules early
when tags are absent or mismatched.

Signed-off-by: Matthew N. Heler <[email protected]>
@mheler
mheler force-pushed the lc-tag-scan-reduction branch from 3c07dfe to f5c1759 Compare December 12, 2025 12:38

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

I think the prefix rule reorganization is well motivated, and author has proved that the size of cached tag info is bounded and not large.

@ivancich ivancich added the wip-eric-testing-1 for ivancich testing label Jan 29, 2026
@ivancich

ivancich commented Feb 3, 2026

Copy link
Copy Markdown
Member

@ivancich
ivancich merged commit deb4a91 into ceph:main Feb 3, 2026
@ivancich

ivancich commented Feb 3, 2026

Copy link
Copy Markdown
Member

@mheler and @mattbenjamin The tracker did not list any backports so this was marked as resolved. If backports are appropriate please fix the tracker. Thanks.

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