From: MingXin Liu Date: Thu, 21 May 2015 12:59:26 +0000 (+0800) Subject: Osd: add a temperature based object eviction policy for cache tiering X-Git-Tag: v10.0.1~72^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ed7d87967dc16953b42bd69278d92600b302a759;p=ceph.git Osd: add a temperature based object eviction policy for cache tiering Signed-off-by: MingXin Liu Reviewed-by: Li Wang --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 9c55e65238f9..3bb7811dd796 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -11521,7 +11521,6 @@ bool ReplicatedPG::agent_work(int start_max, int agent_flush_quota) if (++agent_state->hist_age > g_conf->osd_agent_hist_halflife) { dout(20) << __func__ << " resetting atime and temp histograms" << dendl; agent_state->hist_age = 0; - agent_state->atime_hist.decay(); agent_state->temp_hist.decay(); } @@ -11728,42 +11727,15 @@ bool ReplicatedPG::agent_maybe_evict(ObjectContextRef& obc) if (agent_state->evict_mode != TierAgentState::EVICT_MODE_FULL) { // is this object old and/or cold enough? - int atime = -1, temp = 0; + int temp = 0; + uint64_t temp_upper = 0, temp_lower = 0; if (hit_set) - agent_estimate_atime_temp(soid, &atime, NULL /*FIXME &temp*/); - - uint64_t atime_upper = 0, atime_lower = 0; - if (atime < 0 && obc->obs.oi.mtime != utime_t()) { - if (obc->obs.oi.local_mtime != utime_t()) { - atime = ceph_clock_now(NULL).sec() - obc->obs.oi.local_mtime; - } else { - atime = ceph_clock_now(NULL).sec() - obc->obs.oi.mtime; - } - } - if (atime < 0) { - if (hit_set) { - atime = pool.info.hit_set_period * pool.info.hit_set_count; // "infinite" - } else { - atime_upper = 1000000; - } - } - if (atime >= 0) { - agent_state->atime_hist.add(atime); - agent_state->atime_hist.get_position_micro(atime, &atime_lower, - &atime_upper); - } - - unsigned temp_upper = 0, temp_lower = 0; - /* - // FIXME: bound atime based on creation time? - agent_state->temp_hist.add(atime); + agent_estimate_temp(soid, &temp); + agent_state->temp_hist.add(temp); agent_state->temp_hist.get_position_micro(temp, &temp_lower, &temp_upper); - */ dout(20) << __func__ - << " atime " << atime - << " pos " << atime_lower << "-" << atime_upper - << ", temp " << temp + << " temp " << temp << " pos " << temp_lower << "-" << temp_upper << ", evict_effort " << agent_state->evict_effort << dendl; @@ -11776,9 +11748,7 @@ bool ReplicatedPG::agent_maybe_evict(ObjectContextRef& obc) delete f; *_dout << dendl; - // FIXME: ignore temperature for now. - - if (1000000 - atime_upper >= agent_state->evict_effort) + if (1000000 - temp_upper >= agent_state->evict_effort) return false; } @@ -12062,32 +12032,21 @@ bool ReplicatedPG::agent_choose_mode(bool restart, OpRequestRef op) return requeued; } -void ReplicatedPG::agent_estimate_atime_temp(const hobject_t& oid, - int *atime, int *temp) +void ReplicatedPG::agent_estimate_temp(const hobject_t& oid, int *temp) { assert(hit_set); - *atime = -1; - if (temp) - *temp = 0; - if (hit_set->contains(oid)) { - *atime = 0; - if (temp) - ++(*temp); - else - return; - } - time_t now = ceph_clock_now(NULL).sec(); + assert(temp); + *temp = 0; + if (hit_set->contains(oid)) + *temp = 1000000; + unsigned i = 0; + int last_n = pool.info.hit_set_search_last_n; for (map::reverse_iterator p = - agent_state->hit_set_map.rbegin(); - p != agent_state->hit_set_map.rend(); - ++p) { + agent_state->hit_set_map.rbegin(); last_n > 0 && + p != agent_state->hit_set_map.rend(); ++p, ++i) { if (p->second->contains(oid)) { - if (*atime < 0) - *atime = now - p->first; - if (temp) - ++(*temp); - else - return; + *temp += pool.info.get_grade(i); + --last_n; } } } diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 1b65b5012912..e31c9fdeecbc 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -941,10 +941,8 @@ protected: /// estimate object atime and temperature /// /// @param oid [in] object name - /// @param atime [out] seconds since last access (lower bound) - /// @param temperature [out] relative temperature (# hitset bins we appear in) - void agent_estimate_atime_temp(const hobject_t& oid, - int *atime, int *temperature); + /// @param temperature [out] relative temperature (# consider both access time and frequency) + void agent_estimate_temp(const hobject_t& oid, int *temperature); /// stop the agent void agent_stop(); diff --git a/src/osd/TierAgentState.h b/src/osd/TierAgentState.h index 57f2c72ccf6b..e1665e641868 100644 --- a/src/osd/TierAgentState.h +++ b/src/osd/TierAgentState.h @@ -23,7 +23,6 @@ struct TierAgentState { bool delaying; /// histogram of ages we've encountered - pow2_hist_t atime_hist; pow2_hist_t temp_hist; int hist_age; @@ -109,9 +108,6 @@ struct TierAgentState { f->dump_string("evict_mode", get_evict_mode_name()); f->dump_unsigned("evict_effort", evict_effort); f->dump_stream("position") << position; - f->open_object_section("atime_hist"); - atime_hist.dump(f); - f->close_section(); f->open_object_section("temp_hist"); temp_hist.dump(f); f->close_section();