mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 14:35:52 +00:00
Fix TaggedCache to use uniform logging interface
This commit is contained in:
@@ -47,14 +47,14 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
template <class Key>
|
template <class Key>
|
||||||
inline static LogPartition const& get ()
|
static LogPartition const& get ()
|
||||||
{
|
{
|
||||||
static LogPartition logPartition (getFileName <Key> ());
|
static LogPartition logPartition (getFileName <Key> ());
|
||||||
return logPartition;
|
return logPartition;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SETUP_LOG(k) template <> char const* LogPartition::getFileName <k> () { return __FILE__; }
|
#define SETUP_LOG(k) template <> inline char const* LogPartition::getFileName <k> () { return __FILE__; }
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,7 @@
|
|||||||
|
|
||||||
SETUP_LOG (Application)
|
SETUP_LOG (Application)
|
||||||
|
|
||||||
// VFALCO: TODO, fix this, it might have broken with the Log changes
|
// VFALCO: TODO, fix/clean this, it might have broken with the Log changes
|
||||||
LogPartition TaggedCachePartition("TaggedCache");
|
|
||||||
LogPartition AutoSocketPartition("AutoSocket");
|
LogPartition AutoSocketPartition("AutoSocket");
|
||||||
Application* theApp = NULL;
|
Application* theApp = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#include <boost/ref.hpp>
|
#include <boost/ref.hpp>
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
|
|
||||||
extern LogPartition TaggedCachePartition;
|
|
||||||
extern int upTime();
|
extern int upTime();
|
||||||
|
|
||||||
// This class implements a cache and a map. The cache keeps objects alive
|
// This class implements a cache and a map. The cache keeps objects alive
|
||||||
@@ -23,6 +22,10 @@ extern int upTime();
|
|||||||
// CAUTION: Callers must not modify data objects that are stored in the cache
|
// CAUTION: Callers must not modify data objects that are stored in the cache
|
||||||
// unless they hold their own lock over all cache operations.
|
// unless they hold their own lock over all cache operations.
|
||||||
|
|
||||||
|
struct TaggedCacheLog { };
|
||||||
|
|
||||||
|
SETUP_LOG (TaggedCacheLog)
|
||||||
|
|
||||||
template <typename c_Key, typename c_Data> class TaggedCache
|
template <typename c_Key, typename c_Data> class TaggedCache
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -105,7 +108,7 @@ template<typename c_Key, typename c_Data> void TaggedCache<c_Key, c_Data>::setTa
|
|||||||
mTargetSize = s;
|
mTargetSize = s;
|
||||||
if (s > 0)
|
if (s > 0)
|
||||||
mCache.rehash(static_cast<std::size_t>((s + (s >> 2)) / mCache.max_load_factor() + 1));
|
mCache.rehash(static_cast<std::size_t>((s + (s >> 2)) / mCache.max_load_factor() + 1));
|
||||||
Log(lsDEBUG, TaggedCachePartition) << mName << " target size set to " << s;
|
WriteLog (lsDEBUG, TaggedCacheLog) << mName << " target size set to " << s;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename c_Key, typename c_Data> int TaggedCache<c_Key, c_Data>::getTargetAge() const
|
template<typename c_Key, typename c_Data> int TaggedCache<c_Key, c_Data>::getTargetAge() const
|
||||||
@@ -118,7 +121,7 @@ template<typename c_Key, typename c_Data> void TaggedCache<c_Key, c_Data>::setTa
|
|||||||
{
|
{
|
||||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||||
mTargetAge = s;
|
mTargetAge = s;
|
||||||
Log(lsDEBUG, TaggedCachePartition) << mName << " target age set to " << s;
|
WriteLog (lsDEBUG, TaggedCacheLog) << mName << " target age set to " << s;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename c_Key, typename c_Data> int TaggedCache<c_Key, c_Data>::getCacheSize()
|
template<typename c_Key, typename c_Data> int TaggedCache<c_Key, c_Data>::getCacheSize()
|
||||||
@@ -166,7 +169,7 @@ template<typename c_Key, typename c_Data> void TaggedCache<c_Key, c_Data>::sweep
|
|||||||
target = mLastSweep - (mTargetAge * mTargetSize / mCache.size());
|
target = mLastSweep - (mTargetAge * mTargetSize / mCache.size());
|
||||||
if (target > (mLastSweep - 2))
|
if (target > (mLastSweep - 2))
|
||||||
target = mLastSweep - 2;
|
target = mLastSweep - 2;
|
||||||
Log(lsINFO, TaggedCachePartition) << mName << " is growing fast " <<
|
WriteLog (lsINFO, TaggedCacheLog) << mName << " is growing fast " <<
|
||||||
mCache.size() << " of " << mTargetSize <<
|
mCache.size() << " of " << mTargetSize <<
|
||||||
" aging at " << (mLastSweep - target) << " of " << mTargetAge;
|
" aging at " << (mLastSweep - target) << " of " << mTargetAge;
|
||||||
}
|
}
|
||||||
@@ -205,8 +208,8 @@ template<typename c_Key, typename c_Data> void TaggedCache<c_Key, c_Data>::sweep
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert(cc == mCacheCount);
|
assert(cc == mCacheCount);
|
||||||
if (TaggedCachePartition.doLog(lsTRACE) && (mapRemovals || cacheRemovals))
|
if (ShouldLog (lsTRACE, TaggedCacheLog) && (mapRemovals || cacheRemovals))
|
||||||
Log(lsTRACE, TaggedCachePartition) << mName << ": cache = " << mCache.size() << "-" << cacheRemovals <<
|
WriteLog (lsTRACE, TaggedCacheLog) << mName << ": cache = " << mCache.size() << "-" << cacheRemovals <<
|
||||||
", map-=" << mapRemovals;
|
", map-=" << mapRemovals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user