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