From: Sage Weil Date: Tue, 28 Jan 2014 01:57:53 +0000 (-0800) Subject: osd/ReplicatedPG: add slop to agent mode selection X-Git-Tag: v0.78~166^2~20 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c9daf8e5ea401f5bc2aafd4025991fb4903ffcd4;p=ceph.git osd/ReplicatedPG: add slop to agent mode selection We want to avoid a situation where the agent clicks on and off when the system hovers around a utilization threshold. Particularly for trim, the system can expend a lot of energy doing a minimal amount of work when the effort level is low. To avoid this, enable when we are some amount above the threshold, and do not turn off until we are the same amount below the target. Signed-off-by: Sage Weil --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 7f7dd2ef70cf..40cebf9fccd1 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -393,6 +393,10 @@ OPTION(osd_agent_min_evict_effort, OPT_FLOAT, .05) // decay atime and hist histograms after how many objects go by OPTION(osd_agent_hist_halflife, OPT_INT, 1000) +// must be this amount over the threshold to enable, +// this amount below the threshold to disable. +OPTION(osd_agent_slop, OPT_FLOAT, .02) + OPTION(osd_uuid, OPT_UUID, uuid_d()) OPTION(osd_data, OPT_STR, "/var/lib/ceph/osd/$cluster-$id") OPTION(osd_journal, OPT_STR, "/var/lib/ceph/osd/$cluster-$id/journal") diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 664c2e0f4b5e..d06f0c3dda20 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -10457,23 +10457,35 @@ bool ReplicatedPG::agent_choose_mode() // flush mode TierAgentState::flush_mode_t flush_mode = TierAgentState::FLUSH_MODE_IDLE; - if (dirty_micro > pool.info.cache_target_dirty_ratio_micro) + uint64_t flush_target = pool.info.cache_target_dirty_ratio_micro; + uint64_t flush_slop = (float)flush_target * g_conf->osd_agent_slop; + if (agent_state->flush_mode == TierAgentState::FLUSH_MODE_IDLE) + flush_target += flush_slop; + else + flush_target -= MIN(flush_target, flush_slop); + if (dirty_micro > flush_target) flush_mode = TierAgentState::FLUSH_MODE_ACTIVE; // evict mode TierAgentState::evict_mode_t evict_mode = TierAgentState::EVICT_MODE_IDLE; unsigned evict_effort = 0; + uint64_t evict_target = pool.info.cache_target_full_ratio_micro; + uint64_t evict_slop = (float)evict_target * g_conf->osd_agent_slop; + if (agent_state->evict_mode == TierAgentState::EVICT_MODE_IDLE) + evict_target += evict_slop; + else + evict_target -= MIN(evict_target, evict_slop); if (full_micro > 1000000 || - pool.info.cache_target_full_ratio_micro >= 1000000) { + evict_target >= 1000000) { // evict anything clean evict_mode = TierAgentState::EVICT_MODE_FULL; evict_effort = 1000000; - } else if (full_micro > pool.info.cache_target_full_ratio_micro) { + } else if (full_micro > evict_target) { // set effort in [0..1] range based on where we are between evict_mode = TierAgentState::EVICT_MODE_SOME; - uint64_t over = full_micro - pool.info.cache_target_full_ratio_micro; - uint64_t span = 1000000 - pool.info.cache_target_full_ratio_micro; + uint64_t over = full_micro - evict_target; + uint64_t span = 1000000 - evict_target; evict_effort = MIN(over * 1000000 / span, (unsigned)(1000000.0 * g_conf->osd_agent_min_evict_effort)); }