@ -14,6 +14,7 @@
# include <fstream>
# include <fstream>
# include <iomanip>
# include <iomanip>
# include <iostream>
# include <iostream>
# include <memory>
# include <random>
# include <random>
# include <sstream>
# include <sstream>
@ -650,7 +651,7 @@ void BlockCacheTraceAnalyzer::WriteCorrelationFeaturesToFile(
const std : : map < std : : string , Features > & label_features ,
const std : : map < std : : string , Features > & label_features ,
const std : : map < std : : string , Predictions > & label_predictions ,
const std : : map < std : : string , Predictions > & label_predictions ,
uint32_t max_number_of_values ) const {
uint32_t max_number_of_values ) const {
std : : default_random_engine rand_engine ( static_cast < unsigned int > ( env_ - > NowMicros ( ) ) ) ;
std : : default_random_engine rand_engine ( static_cast < std : : default_random_engine : : result_type > ( env_ - > NowMicros ( ) ) ) ;
for ( auto const & label_feature_vectors : label_features ) {
for ( auto const & label_feature_vectors : label_features ) {
const Features & past = label_feature_vectors . second ;
const Features & past = label_feature_vectors . second ;
auto it = label_predictions . find ( label_feature_vectors . first ) ;
auto it = label_predictions . find ( label_feature_vectors . first ) ;
@ -1170,7 +1171,7 @@ void BlockCacheTraceAnalyzer::WriteReuseLifetime(
}
}
void BlockCacheTraceAnalyzer : : WriteBlockReuseTimeline (
void BlockCacheTraceAnalyzer : : WriteBlockReuseTimeline (
uint64_t reuse_window , bool user_access_only , TraceType block_type ) const {
const uint64_t reuse_window , bool user_access_only , TraceType block_type ) const {
// A map from block key to an array of bools that states whether a block is
// A map from block key to an array of bools that states whether a block is
// accessed in a time window.
// accessed in a time window.
std : : map < uint64_t , std : : vector < bool > > block_accessed ;
std : : map < uint64_t , std : : vector < bool > > block_accessed ;
@ -1209,11 +1210,11 @@ void BlockCacheTraceAnalyzer::WriteBlockReuseTimeline(
TraverseBlocks ( block_callback ) ;
TraverseBlocks ( block_callback ) ;
// A cell is the number of blocks accessed in a reuse window.
// A cell is the number of blocks accessed in a reuse window.
uint64_t reuse_table [ reuse_vector_size ] [ reuse_vector_size ] ;
std : : unique_ptr < uint64_t [ ] > reuse_table ( new uint64_t [ reuse_vector_size * reuse_vector_size ] ) ;
for ( uint64_t start_time = 0 ; start_time < reuse_vector_size ; start_time + + ) {
for ( uint64_t start_time = 0 ; start_time < reuse_vector_size ; start_time + + ) {
// Initialize the reuse_table.
// Initialize the reuse_table.
for ( uint64_t i = 0 ; i < reuse_vector_size ; i + + ) {
for ( uint64_t i = 0 ; i < reuse_vector_size ; i + + ) {
reuse_table [ start_time ] [ i ] = 0 ;
reuse_table [ start_time * reuse_vector_size + i ] = 0 ;
}
}
// Examine all blocks.
// Examine all blocks.
for ( auto const & block : block_accessed ) {
for ( auto const & block : block_accessed ) {
@ -1222,7 +1223,7 @@ void BlockCacheTraceAnalyzer::WriteBlockReuseTimeline(
// This block is accessed at start time and at the current time. We
// This block is accessed at start time and at the current time. We
// increment reuse_table[start_time][i] since it is reused at the ith
// increment reuse_table[start_time][i] since it is reused at the ith
// window.
// window.
reuse_table [ start_time ] [ i ] + + ;
reuse_table [ start_time * reuse_vector_size + i ] + + ;
}
}
}
}
}
}
@ -1250,8 +1251,8 @@ void BlockCacheTraceAnalyzer::WriteBlockReuseTimeline(
if ( j < start_time ) {
if ( j < start_time ) {
row + = " 100.0 " ;
row + = " 100.0 " ;
} else {
} else {
row + = std : : to_string ( percent ( reuse_table [ start_time ] [ j ] ,
row + = std : : to_string ( percent ( reuse_table [ start_time * reuse_vector_size + j ] ,
reuse_table [ start_time ] [ start_time ] ) ) ;
reuse_table [ start_time * reuse_vector_size + start_time ] ) ) ;
}
}
}
}
out < < row < < std : : endl ;
out < < row < < std : : endl ;
@ -1673,7 +1674,7 @@ void BlockCacheTraceAnalyzer::PrintAccessCountStats(bool user_access_only,
if ( bottom_k_index > = bottom_k ) {
if ( bottom_k_index > = bottom_k ) {
break ;
break ;
}
}
std : : map < TableReaderCaller , uint32 _t > caller_naccesses ;
std : : map < TableReaderCaller , uint64 _t > caller_naccesses ;
uint64_t naccesses = 0 ;
uint64_t naccesses = 0 ;
for ( auto const & block_id : naccess_it - > second ) {
for ( auto const & block_id : naccess_it - > second ) {
BlockAccessInfo * block = block_info_map_ . find ( block_id ) - > second ;
BlockAccessInfo * block = block_info_map_ . find ( block_id ) - > second ;