Skip to content

Commit 753a55d

Browse files
kkeshava-akamaimatt-akamai
authored andcommitted
Allow LC listing order to be a configurable threshold
Signed-off-by: mheler <[email protected]>
1 parent bb1109a commit 753a55d

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

src/common/options/rgw.yaml.in

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,29 @@ options:
462462
services:
463463
- rgw
464464
with_legacy: true
465+
- name: rgw_lc_ordered_list_threshold
466+
type: uint
467+
level: dev
468+
desc: Threshold for enabling ordered listing in lifecycle processing.
469+
long_desc: When bucket shard count is below this threshold, lifecycle processing will
470+
use ordered listing for better performance. Above this threshold, unordered listing
471+
is used to avoid excessive OSD requests. A value of 0 disables ordered listing entirely.
472+
default: 500
473+
min: 0
474+
services:
475+
- rgw
476+
with_legacy: true
477+
- name: rgw_lc_list_cnt
478+
type: uint
479+
level: dev
480+
desc: The count of number of objects in per listing of lc processing from each bucket.
481+
long_desc: Number of objects that will be requested when performing a listing request
482+
of a bucket for lifecycle processing.
483+
default: 1000
484+
min: 100
485+
services:
486+
- rgw
487+
with_legacy: true
465488
- name: rgw_restore_debug_interval
466489
type: int
467490
level: dev

src/rgw/rgw_lc.cc

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "rgw_perf_counters.h"
2626
#include "rgw_common.h"
2727
#include "rgw_bucket.h"
28+
#include "rgw_bucket_layout.h"
2829
#include "rgw_lc.h"
2930
#include "rgw_zone.h"
3031
#include "rgw_string.h"
@@ -348,6 +349,19 @@ static bool pass_object_lock_check(rgw::sal::Driver* driver, rgw::sal::Object* o
348349
}
349350
}
350351

352+
/**
353+
* Determines whether to use unordered listing for lifecycle processing.
354+
*
355+
* For buckets with low shard counts, ordered listing is preferred due to better
356+
* performance
357+
*
358+
* For buckets with high shard counts, unordered listing is preferred to avoid
359+
* excess OSD requests
360+
*/
361+
static bool should_list_unordered(const rgw::bucket_index_layout_generation& current_index, uint64_t threshold) {
362+
return current_index.layout.type == rgw::BucketIndexType::Normal
363+
&& rgw::num_shards(current_index.layout.normal) > threshold;
364+
}
351365
class LCObjsLister {
352366
rgw::sal::Driver* driver;
353367
rgw::sal::Bucket* bucket;
@@ -363,7 +377,13 @@ class LCObjsLister {
363377
LCObjsLister(rgw::sal::Driver* _driver, rgw::sal::Bucket* _bucket) :
364378
driver(_driver), bucket(_bucket) {
365379
list_params.list_versions = bucket->versioned();
366-
list_params.allow_unordered = true; // XXX can be unconditionally true, so long as all versions of one object are assured to be on one shard and always ordered on that shard (true today in RADOS)
380+
381+
CephContext* cct = driver->ctx();
382+
uint64_t threshold = cct->_conf.get_val<uint64_t>("rgw_lc_ordered_list_threshold");
383+
384+
const auto& current_index = bucket->get_info().layout.current_index;
385+
list_params.allow_unordered = should_list_unordered(current_index, threshold);
386+
367387
delay_ms = driver->ctx()->_conf.get_val<int64_t>("rgw_lc_thread_delay");
368388
}
369389

@@ -377,7 +397,9 @@ class LCObjsLister {
377397
}
378398

379399
int fetch(const DoutPrefixProvider *dpp) {
380-
int ret = bucket->list(dpp, list_params, 1000, list_results, null_yield);
400+
CephContext* cct = dpp->get_cct();
401+
int cnt = cct->_conf.get_val<uint64_t>("rgw_lc_list_cnt");
402+
int ret = bucket->list(dpp, list_params, cnt, list_results, null_yield);
381403
if (ret < 0) {
382404
return ret;
383405
}
@@ -903,7 +925,12 @@ int RGWLC::handle_multipart_expiration(rgw::sal::Bucket* target,
903925
/* lifecycle processing does not depend on total order, so can
904926
* take advantage of unordered listing optimizations--such as
905927
* operating on one shard at a time */
906-
params.allow_unordered = true;
928+
929+
uint64_t threshold = cct->_conf.get_val<uint64_t>("rgw_lc_ordered_list_threshold");
930+
931+
const auto& current_index = target->get_info().layout.current_index;
932+
params.allow_unordered = should_list_unordered(current_index, threshold);
933+
907934
params.ns = RGW_OBJ_NS_MULTIPART;
908935
params.access_list_filter = MultipartMetaFilter;
909936

0 commit comments

Comments
 (0)