PG recovery throttling and queue processing optimizations
Hello!
I would like to present our optimizations for Ceph, such as priority-based recovery throttling and OSD op queue processing optimizations.
I would also like to see your comments on this patch. Ideas from this patch may be useful for real optimizations. The patch is for latest cuttlefish.
This patch includes two things:
1. Recovery throttling and reordering based on OSD load.
2. Optimization of OpWQ processing.
First of all variables are calculated: PG cost, OSD average load and "prioritized recovery" flag for PG.
OSD average load is calculated as geometric mean of PG costs.
PG cost and PG prioritized recovery flag is set calculate_pg_cost() function. Client and high priority ops increases PG cost and trigger setting of priority flag while backfills decreases.
1. Recovery throttling and reordering based on OSD load.
We insert pauses after every recovery operation. From 0.1 to 5.3 seconds, depending on PG load and the fact if current recovering PG is have high priority.
The formula is:
throttle = pg_recovery_prio ? 0.1 : 0.3 + osd_average_load * throttle_coef
At first PGs with recovery priority flag set are recovered and then another PGs.
2. Optimization of OpWQ processing.
While using "bobtail" release we noticed that ceph spends many time on waiting for pg.lock(). So we modified OpWQ dequeuing and processing code to try to handle ops for another PGs if current pg is already locked.
To achieve this goal we move all incoming ops to "pg_for_processing" map, and process PGs not in incoming order but in descendent order of PG costs, skipping locked PGs.
So op threads will never wait for pg to be unlocked if there are another PGs to process.
With part 1 recovery process does not affect most client operations anymore. Part 2 increased efficiency of op queue processing that affected disk I/O utilization. It gave a great effect on the "bobtail" release, and a small improvement on the "cuttlefish".
Any comments are welcome.
Thanks,
Sergey.
---
src/common/config_opts.h +3 -0
@@ -390,6 +390,9 @@ OPTION(osd_op_pq_min_cost, OPT_U64, 65536) OPTION(osd_disk_threads, OPT_INT, 1) OPTION(osd_recovery_threads, OPT_INT, 1) OPTION(osd_recover_clone_overlap, OPT_BOOL, true) // preserve clone_overlap during recovery/migration +OPTION(osd_recovery_throttle, OPT_FLOAT, 0.3) +OPTION(osd_recovery_throttle_active, OPT_FLOAT, 0.1) +OPTION(osd_recovery_throttle_coef, OPT_FLOAT, 0.08) OPTION(osd_backfill_scan_min, OPT_INT, 64) OPTION(osd_backfill_scan_max, OPT_INT, 512)OPTION (osd_op_thread_timeout,OPT_INT ,15 )
src/include/xlist.h +4 -0
@@ -150,6 +150,7 @@ public: public: iterator(item *i = 0) : cur(i) {} T operator*() { return static_cast<T>(cur->_item); } +item *get_cur () {return cur; } iterator& operator++() {assert (cur);assert (cur->_list);
@@ -161,6 +162,9 @@ public:iterator begin () {return iterator (_front); }iterator end () {return iterator (NULL ); } +void remove (iterator i) { +remove (i.get_cur ()); + } };
src/osd/OSD.cc +258 -18
356 lines not on this page · raw message
src/osd/OSD.h +27 -15
90 lines not on this page · raw message
src/osd/PG.cc +14 -1
@@ -145,7 +145,7 @@ PG::PG(OSDService *o, OSDMapRef curmap, #ifdef PG_DEBUG_REFS _ref_id_lock("PG::_ref_id_lock"), _ref_id(0), #endif - deleting(false), dirty_info(false), dirty_big_info(false), dirty_log(false), + deleting(false), recovery_prio(false), recovery_prio_lock("PG::recovery_prio_lock"), dirty_info(false), dirty_big_info(false), dirty_log(false), info(p), info_struct_v(0), coll(p), log_oid(loid), biginfo_oid(ioid),
@@ -194,6 +194,19 @@ void PG::lock(bool no_lockdep) dout(30) << "lock" << dendl; } +bool PG::try_lock() { + if (!_lock.TryLock()) { + dout(10) << "pg_try_lock_fail " << this << dendl; + return false; + } else { + assert(!dirty_info); + assert(!dirty_log); + + dout(10) << "pg_try_lock " << this << dendl; + return true; + } +} + void PG::lock_with_map_lock_held(bool no_lockdep) { _lock.Lock(no_lockdep);
src/osd/PG.h +3 -0
@@ -413,8 +413,11 @@ protected: public:bool deleting;// true while in removing or OSD is shutting down +bool recovery_prio; +Mutex recovery_prio_lock; void lock(bool no_lockdep = false); +bool try_lock ();void unlock () {//generic_dout(0) << this << " " << info.pgid << " unlock" << dendl; assert (!dirty_info);
Signature · 1 line
1.7.10.4