From: Ning Yao Date: Tue, 23 Dec 2014 05:52:39 +0000 (+0000) Subject: os: WBThrottle: optimize map to unordered_map X-Git-Tag: v0.92~32^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=73257e85f76a39c01c07dbec2b3b41e3b241b7aa;p=ceph.git os: WBThrottle: optimize map to unordered_map Using unordered_map to save the cpu cost and acceralate map::find() operation. Signed-off-by: Ning Yao --- diff --git a/src/os/WBThrottle.cc b/src/os/WBThrottle.cc index 7d0bcf6f45f2..828c84161962 100644 --- a/src/os/WBThrottle.cc +++ b/src/os/WBThrottle.cc @@ -145,7 +145,7 @@ bool WBThrottle::get_next_should_flush( assert(!pending_wbs.empty()); ghobject_t obj(pop_object()); - map >::iterator i = + ceph::unordered_map >::iterator i = pending_wbs.find(obj); *next = boost::make_tuple(obj, i->second.second, i->second.first); pending_wbs.erase(i); @@ -189,7 +189,7 @@ void WBThrottle::queue_wb( bool nocache) { Mutex::Locker l(lock); - map >::iterator wbiter = + ceph::unordered_map >::iterator wbiter = pending_wbs.find(hoid); if (wbiter == pending_wbs.end()) { wbiter = pending_wbs.insert( @@ -215,7 +215,7 @@ void WBThrottle::queue_wb( void WBThrottle::clear() { Mutex::Locker l(lock); - for (map >::iterator i = + for (ceph::unordered_map >::iterator i = pending_wbs.begin(); i != pending_wbs.end(); ++i) { @@ -236,7 +236,7 @@ void WBThrottle::clear_object(const ghobject_t &hoid) Mutex::Locker l(lock); while (clearing == hoid) cond.Wait(lock); - map >::iterator i = + ceph::unordered_map >::iterator i = pending_wbs.find(hoid); if (i == pending_wbs.end()) return; diff --git a/src/os/WBThrottle.h b/src/os/WBThrottle.h index f643e39fad88..b3fd9e01d23c 100644 --- a/src/os/WBThrottle.h +++ b/src/os/WBThrottle.h @@ -15,7 +15,7 @@ #ifndef WBTHROTTLE_H #define WBTHROTTLE_H -#include +#include "include/unordered_map.h" #include #include "include/memory.h" #include "include/buffer.h" @@ -45,7 +45,6 @@ enum { */ class WBThrottle : Thread, public md_config_obs_t { ghobject_t clearing; - /* *_limits.first is the start_flusher limit and * *_limits.second is the hard limit */ @@ -90,10 +89,10 @@ class WBThrottle : Thread, public md_config_obs_t { * Flush objects in lru order */ list lru; - map::iterator> rev_lru; + ceph::unordered_map::iterator> rev_lru; void remove_object(const ghobject_t &oid) { assert(lock.is_locked()); - map::iterator>::iterator iter = + ceph::unordered_map::iterator>::iterator iter = rev_lru.find(oid); if (iter == rev_lru.end()) return; @@ -114,7 +113,7 @@ class WBThrottle : Thread, public md_config_obs_t { rev_lru.insert(make_pair(oid, --lru.end())); } - map > pending_wbs; + ceph::unordered_map > pending_wbs; /// get next flush to perform bool get_next_should_flush(