@ -123,34 +123,42 @@ Status BlockCacheTier::Close() {
return Status : : OK ( ) ;
return Status : : OK ( ) ;
}
}
std : : string BlockCacheTier : : PrintStats ( ) {
template < class T >
std : : ostringstream os ;
void Add ( std : : map < std : : string , double > * stats , const std : : string & key ,
os < < " persistentcache.blockcachetier.bytes_piplined: "
const T & t ) {
< < stats_ . bytes_pipelined_ . ToString ( ) < < std : : endl
stats - > insert ( { key , static_cast < const double > ( t ) } ) ;
< < " persistentcache.blockcachetier.bytes_written: "
}
< < stats_ . bytes_written_ . ToString ( ) < < std : : endl
< < " persistentcache.blockcachetier.bytes_read: "
PersistentCache : : StatsType BlockCacheTier : : Stats ( ) {
< < stats_ . bytes_read_ . ToString ( ) < < std : : endl
std : : map < std : : string , double > stats ;
< < " persistentcache.blockcachetier.insert_dropped "
Add ( & stats , " persistentcache.blockcachetier.bytes_piplined " ,
< < stats_ . insert_dropped_ < < std : : endl
stats_ . bytes_pipelined_ . Average ( ) ) ;
< < " persistentcache.blockcachetier.cache_hits: " < < stats_ . cache_hits_
Add ( & stats , " persistentcache.blockcachetier.bytes_written " ,
< < std : : endl
stats_ . bytes_written_ . Average ( ) ) ;
< < " persistentcache.blockcachetier.cache_misses: " < < stats_ . cache_misses_
Add ( & stats , " persistentcache.blockcachetier.bytes_read " ,
< < std : : endl
stats_ . bytes_read_ . Average ( ) ) ;
< < " persistentcache.blockcachetier.cache_errors: " < < stats_ . cache_errors_
Add ( & stats , " persistentcache.blockcachetier.insert_dropped " ,
< < std : : endl
stats_ . insert_dropped_ ) ;
< < " persistentcache.blockcachetier.cache_hits_pct: "
Add ( & stats , " persistentcache.blockcachetier.cache_hits " ,
< < stats_ . CacheHitPct ( ) < < std : : endl
stats_ . cache_hits_ ) ;
< < " persistentcache.blockcachetier.cache_misses_pct: "
Add ( & stats , " persistentcache.blockcachetier.cache_misses " ,
< < stats_ . CacheMissPct ( ) < < std : : endl
stats_ . cache_misses_ ) ;
< < " persistentcache.blockcachetier.read_hit_latency: "
Add ( & stats , " persistentcache.blockcachetier.cache_errors " ,
< < stats_ . read_hit_latency_ . ToString ( ) < < std : : endl
stats_ . cache_errors_ ) ;
< < " persistentcache.blockcachetier.read_miss_latency: "
Add ( & stats , " persistentcache.blockcachetier.cache_hits_pct " ,
< < stats_ . read_miss_latency_ . ToString ( ) < < std : : endl
stats_ . CacheHitPct ( ) ) ;
< < " persistenetcache.blockcachetier.write_latency: "
Add ( & stats , " persistentcache.blockcachetier.cache_misses_pct " ,
< < stats_ . write_latency_ . ToString ( ) < < std : : endl
stats_ . CacheMissPct ( ) ) ;
< < PersistentCacheTier : : PrintStats ( ) ;
Add ( & stats , " persistentcache.blockcachetier.read_hit_latency " ,
return os . str ( ) ;
stats_ . read_hit_latency_ . Average ( ) ) ;
Add ( & stats , " persistentcache.blockcachetier.read_miss_latency " ,
stats_ . read_miss_latency_ . Average ( ) ) ;
Add ( & stats , " persistenetcache.blockcachetier.write_latency " ,
stats_ . write_latency_ . Average ( ) ) ;
auto out = PersistentCacheTier : : Stats ( ) ;
out . push_back ( stats ) ;
return out ;
}
}
Status BlockCacheTier : : Insert ( const Slice & key , const char * data ,
Status BlockCacheTier : : Insert ( const Slice & key , const char * data ,