@ -864,33 +864,24 @@ TEST_P(PrefetchTest, PrefetchWhenReseekwithCache) {
Close ( ) ;
Close ( ) ;
}
}
class PrefetchTest1
: public DBTestBase ,
public : : testing : : WithParamInterface < std : : tuple < bool , bool > > {
public :
PrefetchTest1 ( ) : DBTestBase ( " prefetch_test1 " , true ) { }
} ;
INSTANTIATE_TEST_CASE_P ( PrefetchTest1 , PrefetchTest1 ,
: : testing : : Combine ( : : testing : : Bool ( ) ,
: : testing : : Bool ( ) ) ) ;
# ifndef ROCKSDB_LITE
# ifndef ROCKSDB_LITE
TEST_P ( PrefetchTest1 , DBIterLevelReadAhead ) {
TEST_P ( PrefetchTest , DBIterLevelReadAhead ) {
const int kNumKeys = 1000 ;
const int kNumKeys = 1000 ;
// Set options
// Set options
std : : shared_ptr < MockFS > fs =
std : : shared_ptr < MockFS > fs =
std : : make_shared < MockFS > ( env_ - > GetFileSystem ( ) , false ) ;
std : : make_shared < MockFS > ( env_ - > GetFileSystem ( ) , false ) ;
std : : unique_ptr < Env > env ( new CompositeEnvWrapper ( env_ , fs ) ) ;
std : : unique_ptr < Env > env ( new CompositeEnvWrapper ( env_ , fs ) ) ;
bool use_direct_io = std : : get < 0 > ( GetParam ( ) ) ;
bool is_adaptive_readahead = std : : get < 1 > ( GetParam ( ) ) ;
bool is_adaptive_readahead = std : : get < 1 > ( GetParam ( ) ) ;
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
options . write_buffer_size = 1024 ;
options . write_buffer_size = 1024 ;
options . create_if_missing = true ;
options . create_if_missing = true ;
options . compression = kNoCompression ;
options . compression = kNoCompression ;
options . statistics = CreateDBStatistics ( ) ;
options . statistics = CreateDBStatistics ( ) ;
options . env = env . get ( ) ;
options . env = env . get ( ) ;
bool use_direct_io = std : : get < 0 > ( GetParam ( ) ) ;
if ( use_direct_io ) {
if ( use_direct_io ) {
options . use_direct_reads = true ;
options . use_direct_reads = true ;
options . use_direct_io_for_flush_and_compaction = true ;
options . use_direct_io_for_flush_and_compaction = true ;
@ -987,7 +978,7 @@ TEST_P(PrefetchTest1, DBIterLevelReadAhead) {
{
{
HistogramData async_read_bytes ;
HistogramData async_read_bytes ;
options . statistics - > histogramData ( ASYNC_READ_BYTES , & async_read_bytes ) ;
options . statistics - > histogramData ( ASYNC_READ_BYTES , & async_read_bytes ) ;
if ( ro . async_io & & ! use_direct_io ) {
if ( ro . async_io ) {
ASSERT_GT ( async_read_bytes . count , 0 ) ;
ASSERT_GT ( async_read_bytes . count , 0 ) ;
} else {
} else {
ASSERT_EQ ( async_read_bytes . count , 0 ) ;
ASSERT_EQ ( async_read_bytes . count , 0 ) ;
@ -1001,16 +992,16 @@ TEST_P(PrefetchTest1, DBIterLevelReadAhead) {
}
}
# endif //! ROCKSDB_LITE
# endif //! ROCKSDB_LITE
class PrefetchTest2 : public DBTestBase ,
class PrefetchTest1 : public DBTestBase ,
public : : testing : : WithParamInterface < bool > {
public : : testing : : WithParamInterface < bool > {
public :
public :
PrefetchTest2 ( ) : DBTestBase ( " prefetch_test2 " , true ) { }
PrefetchTest1 ( ) : DBTestBase ( " prefetch_test1 " , true ) { }
} ;
} ;
INSTANTIATE_TEST_CASE_P ( PrefetchTest2 , PrefetchTest2 , : : testing : : Bool ( ) ) ;
INSTANTIATE_TEST_CASE_P ( PrefetchTest1 , PrefetchTest1 , : : testing : : Bool ( ) ) ;
# ifndef ROCKSDB_LITE
# ifndef ROCKSDB_LITE
TEST_P ( PrefetchTest2 , NonSequentialReadsWithAdaptiveReadahead ) {
TEST_P ( PrefetchTest1 , NonSequentialReadsWithAdaptiveReadahead ) {
const int kNumKeys = 1000 ;
const int kNumKeys = 1000 ;
// Set options
// Set options
std : : shared_ptr < MockFS > fs =
std : : shared_ptr < MockFS > fs =
@ -1103,7 +1094,7 @@ TEST_P(PrefetchTest2, NonSequentialReadsWithAdaptiveReadahead) {
}
}
# endif //! ROCKSDB_LITE
# endif //! ROCKSDB_LITE
TEST_P ( PrefetchTest2 , DecreaseReadAheadIfInCache ) {
TEST_P ( PrefetchTest1 , DecreaseReadAheadIfInCache ) {
const int kNumKeys = 2000 ;
const int kNumKeys = 2000 ;
// Set options
// Set options
std : : shared_ptr < MockFS > fs =
std : : shared_ptr < MockFS > fs =
@ -1167,7 +1158,6 @@ TEST_P(PrefetchTest2, DecreaseReadAheadIfInCache) {
SyncPoint : : GetInstance ( ) - > EnableProcessing ( ) ;
SyncPoint : : GetInstance ( ) - > EnableProcessing ( ) ;
ReadOptions ro ;
ReadOptions ro ;
ro . adaptive_readahead = true ;
ro . adaptive_readahead = true ;
// ro.async_io = true;
{
{
/*
/*
* Reseek keys from sequential Data Blocks within same partitioned
* Reseek keys from sequential Data Blocks within same partitioned
@ -1248,7 +1238,7 @@ TEST_P(PrefetchTest2, DecreaseReadAheadIfInCache) {
Close ( ) ;
Close ( ) ;
}
}
TEST_P ( PrefetchTest2 , SeekParallelizationTest ) {
TEST_P ( PrefetchTest1 , SeekParallelizationTest ) {
const int kNumKeys = 2000 ;
const int kNumKeys = 2000 ;
// Set options
// Set options
std : : shared_ptr < MockFS > fs =
std : : shared_ptr < MockFS > fs =
@ -1341,13 +1331,9 @@ TEST_P(PrefetchTest2, SeekParallelizationTest) {
{
{
HistogramData async_read_bytes ;
HistogramData async_read_bytes ;
options . statistics - > histogramData ( ASYNC_READ_BYTES , & async_read_bytes ) ;
options . statistics - > histogramData ( ASYNC_READ_BYTES , & async_read_bytes ) ;
if ( GetParam ( ) ) {
ASSERT_EQ ( async_read_bytes . count , 0 ) ;
} else {
ASSERT_GT ( async_read_bytes . count , 0 ) ;
ASSERT_GT ( async_read_bytes . count , 0 ) ;
ASSERT_GT ( get_perf_context ( ) - > number_async_seek , 0 ) ;
ASSERT_GT ( get_perf_context ( ) - > number_async_seek , 0 ) ;
}
}
}
buff_prefetch_count = 0 ;
buff_prefetch_count = 0 ;
}
}
@ -1356,11 +1342,7 @@ TEST_P(PrefetchTest2, SeekParallelizationTest) {
extern " C " bool RocksDbIOUringEnable ( ) { return true ; }
extern " C " bool RocksDbIOUringEnable ( ) { return true ; }
class PrefetchTestWithPosix : public DBTestBase ,
namespace {
public : : testing : : WithParamInterface < bool > {
public :
PrefetchTestWithPosix ( ) : DBTestBase ( " prefetch_test_with_posix " , true ) { }
# ifndef ROCKSDB_LITE
# ifndef ROCKSDB_LITE
# ifdef GFLAGS
# ifdef GFLAGS
const int kMaxArgCount = 100 ;
const int kMaxArgCount = 100 ;
@ -1387,13 +1369,10 @@ class PrefetchTestWithPosix : public DBTestBase,
}
}
# endif // GFLAGS
# endif // GFLAGS
# endif // ROCKSDB_LITE
# endif // ROCKSDB_LITE
} ;
} // namespace
INSTANTIATE_TEST_CASE_P ( PrefetchTestWithPosix , PrefetchTestWithPosix ,
: : testing : : Bool ( ) ) ;
// Tests the default implementation of ReadAsync API with PosixFileSystem.
// Tests the default implementation of ReadAsync API with PosixFileSystem.
TEST_P ( PrefetchTestWithPosix , ReadAsyncWithPosixFS ) {
TEST_P ( PrefetchTest , ReadAsyncWithPosixFS ) {
if ( mem_env_ | | encrypted_env_ ) {
if ( mem_env_ | | encrypted_env_ ) {
ROCKSDB_GTEST_SKIP ( " Test requires non-mem or non-encrypted environment " ) ;
ROCKSDB_GTEST_SKIP ( " Test requires non-mem or non-encrypted environment " ) ;
return ;
return ;
@ -1404,7 +1383,7 @@ TEST_P(PrefetchTestWithPosix, ReadAsyncWithPosixFS) {
FileSystem : : Default ( ) , /*support_prefetch=*/ false ) ;
FileSystem : : Default ( ) , /*support_prefetch=*/ false ) ;
std : : unique_ptr < Env > env ( new CompositeEnvWrapper ( env_ , fs ) ) ;
std : : unique_ptr < Env > env ( new CompositeEnvWrapper ( env_ , fs ) ) ;
bool use_direct_io = false ;
bool use_direct_io = std : : get < 0 > ( GetParam ( ) ) ;
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
options . write_buffer_size = 1024 ;
options . write_buffer_size = 1024 ;
options . create_if_missing = true ;
options . create_if_missing = true ;
@ -1453,7 +1432,7 @@ TEST_P(PrefetchTestWithPosix, ReadAsyncWithPosixFS) {
ro . adaptive_readahead = true ;
ro . adaptive_readahead = true ;
ro . async_io = true ;
ro . async_io = true ;
if ( GetParam ( ) ) {
if ( std : : get < 1 > ( GetParam ( ) ) ) {
ro . readahead_size = 16 * 1024 ;
ro . readahead_size = 16 * 1024 ;
}
}
@ -1530,7 +1509,8 @@ TEST_P(PrefetchTestWithPosix, ReadAsyncWithPosixFS) {
// Check stats to make sure async prefetch is done.
// Check stats to make sure async prefetch is done.
{
{
HistogramData async_read_bytes ;
HistogramData async_read_bytes ;
options . statistics - > histogramData ( ASYNC_READ_BYTES , & async_read_bytes ) ;
options . statistics - > histogramData ( ASYNC_READ_BYTES ,
& async_read_bytes ) ;
HistogramData prefetched_bytes_discarded ;
HistogramData prefetched_bytes_discarded ;
options . statistics - > histogramData ( PREFETCHED_BYTES_DISCARDED ,
options . statistics - > histogramData ( PREFETCHED_BYTES_DISCARDED ,
& prefetched_bytes_discarded ) ;
& prefetched_bytes_discarded ) ;
@ -1557,7 +1537,7 @@ TEST_P(PrefetchTestWithPosix, ReadAsyncWithPosixFS) {
# ifndef ROCKSDB_LITE
# ifndef ROCKSDB_LITE
# ifdef GFLAGS
# ifdef GFLAGS
TEST_P ( PrefetchTestWithPosix , TraceReadAsyncWithCallbackWrapper ) {
TEST_P ( PrefetchTest , TraceReadAsyncWithCallbackWrapper ) {
if ( mem_env_ | | encrypted_env_ ) {
if ( mem_env_ | | encrypted_env_ ) {
ROCKSDB_GTEST_SKIP ( " Test requires non-mem or non-encrypted environment " ) ;
ROCKSDB_GTEST_SKIP ( " Test requires non-mem or non-encrypted environment " ) ;
return ;
return ;
@ -1568,7 +1548,7 @@ TEST_P(PrefetchTestWithPosix, TraceReadAsyncWithCallbackWrapper) {
FileSystem : : Default ( ) , /*support_prefetch=*/ false ) ;
FileSystem : : Default ( ) , /*support_prefetch=*/ false ) ;
std : : unique_ptr < Env > env ( new CompositeEnvWrapper ( env_ , fs ) ) ;
std : : unique_ptr < Env > env ( new CompositeEnvWrapper ( env_ , fs ) ) ;
bool use_direct_io = false ;
bool use_direct_io = std : : get < 0 > ( GetParam ( ) ) ;
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
options . write_buffer_size = 1024 ;
options . write_buffer_size = 1024 ;
options . create_if_missing = true ;
options . create_if_missing = true ;
@ -1617,7 +1597,7 @@ TEST_P(PrefetchTestWithPosix, TraceReadAsyncWithCallbackWrapper) {
ro . adaptive_readahead = true ;
ro . adaptive_readahead = true ;
ro . async_io = true ;
ro . async_io = true ;
if ( GetParam ( ) ) {
if ( std : : get < 1 > ( GetParam ( ) ) ) {
ro . readahead_size = 16 * 1024 ;
ro . readahead_size = 16 * 1024 ;
}
}
@ -1638,8 +1618,8 @@ TEST_P(PrefetchTestWithPosix, TraceReadAsyncWithCallbackWrapper) {
std : : unique_ptr < TraceWriter > trace_writer ;
std : : unique_ptr < TraceWriter > trace_writer ;
std : : string trace_file_path = dbname_ + " /io_trace_file " ;
std : : string trace_file_path = dbname_ + " /io_trace_file " ;
ASSERT_OK (
ASSERT_OK ( NewFileTraceWriter ( env_ , EnvOptions ( ) , trace_file_path ,
NewFileTraceWriter ( env_ , EnvOptions ( ) , trace_file_path , & trace_writer ) ) ;
& trace_writer ) ) ;
ASSERT_OK ( db_ - > StartIOTrace ( trace_opt , std : : move ( trace_writer ) ) ) ;
ASSERT_OK ( db_ - > StartIOTrace ( trace_opt , std : : move ( trace_writer ) ) ) ;
ASSERT_OK ( options . statistics - > Reset ( ) ) ;
ASSERT_OK ( options . statistics - > Reset ( ) ) ;