@ -688,6 +688,10 @@ DEFINE_bool(memtable_whole_key_filtering, false,
DEFINE_bool ( memtable_use_huge_page , false ,
DEFINE_bool ( memtable_use_huge_page , false ,
" Try to use huge page in memtables. " ) ;
" Try to use huge page in memtables. " ) ;
DEFINE_bool ( whole_key_filtering ,
ROCKSDB_NAMESPACE : : BlockBasedTableOptions ( ) . whole_key_filtering ,
" Use whole keys (in addition to prefixes) in SST bloom filter. " ) ;
DEFINE_bool ( use_existing_db , false , " If true, do not destroy the existing "
DEFINE_bool ( use_existing_db , false , " If true, do not destroy the existing "
" database. If you set this flag and also specify a benchmark that "
" database. If you set this flag and also specify a benchmark that "
" wants a fresh database, that benchmark will fail. " ) ;
" wants a fresh database, that benchmark will fail. " ) ;
@ -2622,6 +2626,7 @@ class Benchmark {
int64_t writes_per_range_tombstone_ ;
int64_t writes_per_range_tombstone_ ;
int64_t range_tombstone_width_ ;
int64_t range_tombstone_width_ ;
int64_t max_num_range_tombstones_ ;
int64_t max_num_range_tombstones_ ;
ReadOptions read_options_ ;
WriteOptions write_options_ ;
WriteOptions write_options_ ;
Options open_options_ ; // keep options around to properly destroy db later
Options open_options_ ; // keep options around to properly destroy db later
# ifndef ROCKSDB_LITE
# ifndef ROCKSDB_LITE
@ -3245,6 +3250,12 @@ class Benchmark {
write_options_ . sync = true ;
write_options_ . sync = true ;
}
}
write_options_ . disableWAL = FLAGS_disable_wal ;
write_options_ . disableWAL = FLAGS_disable_wal ;
read_options_ = ReadOptions ( FLAGS_verify_checksum , true ) ;
read_options_ . total_order_seek = FLAGS_total_order_seek ;
read_options_ . prefix_same_as_start = FLAGS_prefix_same_as_start ;
read_options_ . tailing = FLAGS_use_tailing_iterator ;
read_options_ . readahead_size = FLAGS_readahead_size ;
read_options_ . adaptive_readahead = FLAGS_adaptive_readahead ;
void ( Benchmark : : * method ) ( ThreadState * ) = nullptr ;
void ( Benchmark : : * method ) ( ThreadState * ) = nullptr ;
void ( Benchmark : : * post_process_method ) ( ) = nullptr ;
void ( Benchmark : : * post_process_method ) ( ) = nullptr ;
@ -4163,6 +4174,7 @@ class Benchmark {
block_based_options . enable_index_compression =
block_based_options . enable_index_compression =
FLAGS_enable_index_compression ;
FLAGS_enable_index_compression ;
block_based_options . block_align = FLAGS_block_align ;
block_based_options . block_align = FLAGS_block_align ;
block_based_options . whole_key_filtering = FLAGS_whole_key_filtering ;
BlockBasedTableOptions : : PrepopulateBlockCache prepopulate_block_cache =
BlockBasedTableOptions : : PrepopulateBlockCache prepopulate_block_cache =
block_based_options . prepopulate_block_cache ;
block_based_options . prepopulate_block_cache ;
switch ( FLAGS_prepopulate_block_cache ) {
switch ( FLAGS_prepopulate_block_cache ) {
@ -4484,7 +4496,7 @@ class Benchmark {
if ( FLAGS_use_existing_keys ) {
if ( FLAGS_use_existing_keys ) {
// Only work on single database
// Only work on single database
assert ( db_ . db ! = nullptr ) ;
assert ( db_ . db ! = nullptr ) ;
ReadOptions read_opts ;
ReadOptions read_opts ; // before read_options_ initialized
read_opts . total_order_seek = true ;
read_opts . total_order_seek = true ;
Iterator * iter = db_ . db - > NewIterator ( read_opts ) ;
Iterator * iter = db_ . db - > NewIterator ( read_opts ) ;
for ( iter - > SeekToFirst ( ) ; iter - > Valid ( ) ; iter - > Next ( ) ) {
for ( iter - > SeekToFirst ( ) ; iter - > Valid ( ) ; iter - > Next ( ) ) {
@ -5483,8 +5495,7 @@ class Benchmark {
}
}
void ReadSequential ( ThreadState * thread , DB * db ) {
void ReadSequential ( ThreadState * thread , DB * db ) {
ReadOptions options ( FLAGS_verify_checksum , true ) ;
ReadOptions options = read_options_ ;
options . tailing = FLAGS_use_tailing_iterator ;
std : : unique_ptr < char [ ] > ts_guard ;
std : : unique_ptr < char [ ] > ts_guard ;
Slice ts ;
Slice ts ;
if ( user_timestamp_size_ > 0 ) {
if ( user_timestamp_size_ > 0 ) {
@ -5523,7 +5534,6 @@ class Benchmark {
int64_t found = 0 ;
int64_t found = 0 ;
int64_t bytes = 0 ;
int64_t bytes = 0 ;
int64_t key_rand = 0 ;
int64_t key_rand = 0 ;
ReadOptions options ( FLAGS_verify_checksum , true ) ;
std : : unique_ptr < const char [ ] > key_guard ;
std : : unique_ptr < const char [ ] > key_guard ;
Slice key = AllocateKey ( & key_guard ) ;
Slice key = AllocateKey ( & key_guard ) ;
PinnableSlice pinnable_val ;
PinnableSlice pinnable_val ;
@ -5538,11 +5548,11 @@ class Benchmark {
read + + ;
read + + ;
Status s ;
Status s ;
if ( FLAGS_num_column_families > 1 ) {
if ( FLAGS_num_column_families > 1 ) {
s = db_with_cfh - > db - > Get ( options , db_with_cfh - > GetCfh ( key_rand ) , key ,
s = db_with_cfh - > db - > Get ( read_ options_ , db_with_cfh - > GetCfh ( key_rand ) ,
& pinnable_val ) ;
key , & pinnable_val ) ;
} else {
} else {
pinnable_val . Reset ( ) ;
pinnable_val . Reset ( ) ;
s = db_with_cfh - > db - > Get ( options ,
s = db_with_cfh - > db - > Get ( read_ options_ ,
db_with_cfh - > db - > DefaultColumnFamily ( ) , key ,
db_with_cfh - > db - > DefaultColumnFamily ( ) , key ,
& pinnable_val ) ;
& pinnable_val ) ;
}
}
@ -5588,9 +5598,7 @@ class Benchmark {
}
}
void ReadReverse ( ThreadState * thread , DB * db ) {
void ReadReverse ( ThreadState * thread , DB * db ) {
ReadOptions options ( FLAGS_verify_checksum , true ) ;
Iterator * iter = db - > NewIterator ( read_options_ ) ;
options . adaptive_readahead = FLAGS_adaptive_readahead ;
Iterator * iter = db - > NewIterator ( options ) ;
int64_t i = 0 ;
int64_t i = 0 ;
int64_t bytes = 0 ;
int64_t bytes = 0 ;
for ( iter - > SeekToLast ( ) ; i < reads_ & & iter - > Valid ( ) ; iter - > Prev ( ) ) {
for ( iter - > SeekToLast ( ) ; i < reads_ & & iter - > Valid ( ) ; iter - > Prev ( ) ) {
@ -5612,7 +5620,7 @@ class Benchmark {
int64_t read = 0 ;
int64_t read = 0 ;
int64_t found = 0 ;
int64_t found = 0 ;
int64_t nonexist = 0 ;
int64_t nonexist = 0 ;
ReadOptions options ( FLAGS_verify_checksum , true ) ;
ReadOptions options = read_options_ ;
std : : unique_ptr < const char [ ] > key_guard ;
std : : unique_ptr < const char [ ] > key_guard ;
Slice key = AllocateKey ( & key_guard ) ;
Slice key = AllocateKey ( & key_guard ) ;
std : : string value ;
std : : string value ;
@ -5702,7 +5710,7 @@ class Benchmark {
int64_t bytes = 0 ;
int64_t bytes = 0 ;
int num_keys = 0 ;
int num_keys = 0 ;
int64_t key_rand = 0 ;
int64_t key_rand = 0 ;
ReadOptions options ( FLAGS_verify_checksum , true ) ;
ReadOptions options = read_options_ ;
std : : unique_ptr < const char [ ] > key_guard ;
std : : unique_ptr < const char [ ] > key_guard ;
Slice key = AllocateKey ( & key_guard ) ;
Slice key = AllocateKey ( & key_guard ) ;
PinnableSlice pinnable_val ;
PinnableSlice pinnable_val ;
@ -5788,7 +5796,7 @@ class Benchmark {
int64_t bytes = 0 ;
int64_t bytes = 0 ;
int64_t num_multireads = 0 ;
int64_t num_multireads = 0 ;
int64_t found = 0 ;
int64_t found = 0 ;
ReadOptions options ( FLAGS_verify_checksum , true ) ;
ReadOptions options = read_options_ ;
std : : vector < Slice > keys ;
std : : vector < Slice > keys ;
std : : vector < std : : unique_ptr < const char [ ] > > key_guards ;
std : : vector < std : : unique_ptr < const char [ ] > > key_guards ;
std : : vector < std : : string > values ( entries_per_batch_ ) ;
std : : vector < std : : string > values ( entries_per_batch_ ) ;
@ -6170,7 +6178,6 @@ class Benchmark {
value_max = FLAGS_mix_max_value_size ;
value_max = FLAGS_mix_max_value_size ;
}
}
ReadOptions options ( FLAGS_verify_checksum , true ) ;
std : : unique_ptr < const char [ ] > key_guard ;
std : : unique_ptr < const char [ ] > key_guard ;
Slice key = AllocateKey ( & key_guard ) ;
Slice key = AllocateKey ( & key_guard ) ;
PinnableSlice pinnable_val ;
PinnableSlice pinnable_val ;
@ -6253,11 +6260,11 @@ class Benchmark {
gets + + ;
gets + + ;
read + + ;
read + + ;
if ( FLAGS_num_column_families > 1 ) {
if ( FLAGS_num_column_families > 1 ) {
s = db_with_cfh - > db - > Get ( options , db_with_cfh - > GetCfh ( key_rand ) , key ,
s = db_with_cfh - > db - > Get ( read_ options_ , db_with_cfh - > GetCfh ( key_rand ) ,
& pinnable_val ) ;
key , & pinnable_val ) ;
} else {
} else {
pinnable_val . Reset ( ) ;
pinnable_val . Reset ( ) ;
s = db_with_cfh - > db - > Get ( options ,
s = db_with_cfh - > db - > Get ( read_ options_ ,
db_with_cfh - > db - > DefaultColumnFamily ( ) , key ,
db_with_cfh - > db - > DefaultColumnFamily ( ) , key ,
& pinnable_val ) ;
& pinnable_val ) ;
}
}
@ -6302,7 +6309,7 @@ class Benchmark {
// Seek query
// Seek query
if ( db_with_cfh - > db ! = nullptr ) {
if ( db_with_cfh - > db ! = nullptr ) {
Iterator * single_iter = nullptr ;
Iterator * single_iter = nullptr ;
single_iter = db_with_cfh - > db - > NewIterator ( options ) ;
single_iter = db_with_cfh - > db - > NewIterator ( read_ options_ ) ;
if ( single_iter ! = nullptr ) {
if ( single_iter ! = nullptr ) {
single_iter - > Seek ( key ) ;
single_iter - > Seek ( key ) ;
seek + + ;
seek + + ;
@ -6345,7 +6352,7 @@ class Benchmark {
void IteratorCreation ( ThreadState * thread ) {
void IteratorCreation ( ThreadState * thread ) {
Duration duration ( FLAGS_duration , reads_ ) ;
Duration duration ( FLAGS_duration , reads_ ) ;
ReadOptions options ( FLAGS_verify_checksum , true ) ;
ReadOptions options = read_options_ ;
std : : unique_ptr < char [ ] > ts_guard ;
std : : unique_ptr < char [ ] > ts_guard ;
if ( user_timestamp_size_ > 0 ) {
if ( user_timestamp_size_ > 0 ) {
ts_guard . reset ( new char [ user_timestamp_size_ ] ) ;
ts_guard . reset ( new char [ user_timestamp_size_ ] ) ;
@ -6375,12 +6382,7 @@ class Benchmark {
int64_t read = 0 ;
int64_t read = 0 ;
int64_t found = 0 ;
int64_t found = 0 ;
int64_t bytes = 0 ;
int64_t bytes = 0 ;
ReadOptions options ( FLAGS_verify_checksum , true ) ;
ReadOptions options = read_options_ ;
options . total_order_seek = FLAGS_total_order_seek ;
options . prefix_same_as_start = FLAGS_prefix_same_as_start ;
options . tailing = FLAGS_use_tailing_iterator ;
options . readahead_size = FLAGS_readahead_size ;
options . adaptive_readahead = FLAGS_adaptive_readahead ;
std : : unique_ptr < char [ ] > ts_guard ;
std : : unique_ptr < char [ ] > ts_guard ;
Slice ts ;
Slice ts ;
if ( user_timestamp_size_ > 0 ) {
if ( user_timestamp_size_ > 0 ) {
@ -6669,7 +6671,7 @@ class Benchmark {
abort ( ) ;
abort ( ) ;
}
}
assert ( db_ . db ! = nullptr ) ;
assert ( db_ . db ! = nullptr ) ;
ReadOptions read_options ;
ReadOptions read_options = read_options_ ;
std : : unique_ptr < char [ ] > ts_guard ;
std : : unique_ptr < char [ ] > ts_guard ;
Slice ts ;
Slice ts ;
if ( user_timestamp_size_ > 0 ) {
if ( user_timestamp_size_ > 0 ) {
@ -6677,7 +6679,6 @@ class Benchmark {
ts = mock_app_clock_ - > GetTimestampForRead ( thread - > rand , ts_guard . get ( ) ) ;
ts = mock_app_clock_ - > GetTimestampForRead ( thread - > rand , ts_guard . get ( ) ) ;
read_options . timestamp = & ts ;
read_options . timestamp = & ts ;
}
}
read_options . adaptive_readahead = FLAGS_adaptive_readahead ;
Iterator * iter = db_ . db - > NewIterator ( read_options ) ;
Iterator * iter = db_ . db - > NewIterator ( read_options ) ;
fprintf ( stderr , " num reads to do % " PRIu64 " \n " , reads_ ) ;
fprintf ( stderr , " num reads to do % " PRIu64 " \n " , reads_ ) ;
@ -6767,13 +6768,12 @@ class Benchmark {
// Given a key K and value V, this gets values for K+"0", K+"1" and K+"2"
// Given a key K and value V, this gets values for K+"0", K+"1" and K+"2"
// in the same snapshot, and verifies that all the values are identical.
// in the same snapshot, and verifies that all the values are identical.
// ASSUMES that PutMany was used to put (K, V) into the DB.
// ASSUMES that PutMany was used to put (K, V) into the DB.
Status GetMany ( DB * db , const ReadOptions & readoptions , const Slice & key ,
Status GetMany ( DB * db , const Slice & key , std : : string * value ) {
std : : string * value ) {
std : : string suffixes [ 3 ] = { " 0 " , " 1 " , " 2 " } ;
std : : string suffixes [ 3 ] = { " 0 " , " 1 " , " 2 " } ;
std : : string keys [ 3 ] ;
std : : string keys [ 3 ] ;
Slice key_slices [ 3 ] ;
Slice key_slices [ 3 ] ;
std : : string values [ 3 ] ;
std : : string values [ 3 ] ;
ReadOptions readoptionscopy = readoptions ;
ReadOptions readoptionscopy = read_ options_ ;
std : : unique_ptr < char [ ] > ts_guard ;
std : : unique_ptr < char [ ] > ts_guard ;
Slice ts ;
Slice ts ;
@ -6821,7 +6821,6 @@ class Benchmark {
// FLAGS_numdistinct distinct keys instead of FLAGS_num distinct keys.
// FLAGS_numdistinct distinct keys instead of FLAGS_num distinct keys.
// (d) Does not have a MultiGet option.
// (d) Does not have a MultiGet option.
void RandomWithVerify ( ThreadState * thread ) {
void RandomWithVerify ( ThreadState * thread ) {
ReadOptions options ( FLAGS_verify_checksum , true ) ;
RandomGenerator gen ;
RandomGenerator gen ;
std : : string value ;
std : : string value ;
int64_t found = 0 ;
int64_t found = 0 ;
@ -6848,7 +6847,7 @@ class Benchmark {
FLAGS_numdistinct , & key ) ;
FLAGS_numdistinct , & key ) ;
if ( get_weight > 0 ) {
if ( get_weight > 0 ) {
// do all the gets first
// do all the gets first
Status s = GetMany ( db , options , key , & value ) ;
Status s = GetMany ( db , key , & value ) ;
if ( ! s . ok ( ) & & ! s . IsNotFound ( ) ) {
if ( ! s . ok ( ) & & ! s . IsNotFound ( ) ) {
fprintf ( stderr , " getmany error: %s \n " , s . ToString ( ) . c_str ( ) ) ;
fprintf ( stderr , " getmany error: %s \n " , s . ToString ( ) . c_str ( ) ) ;
// we continue after error rather than exiting so that we can
// we continue after error rather than exiting so that we can
@ -6892,7 +6891,7 @@ class Benchmark {
// This is different from ReadWhileWriting because it does not use
// This is different from ReadWhileWriting because it does not use
// an extra thread.
// an extra thread.
void ReadRandomWriteRandom ( ThreadState * thread ) {
void ReadRandomWriteRandom ( ThreadState * thread ) {
ReadOptions options ( FLAGS_verify_checksum , true ) ;
ReadOptions options = read_options_ ;
RandomGenerator gen ;
RandomGenerator gen ;
std : : string value ;
std : : string value ;
int64_t found = 0 ;
int64_t found = 0 ;
@ -6966,7 +6965,7 @@ class Benchmark {
//
//
// Read-modify-write for random keys
// Read-modify-write for random keys
void UpdateRandom ( ThreadState * thread ) {
void UpdateRandom ( ThreadState * thread ) {
ReadOptions options ( FLAGS_verify_checksum , true ) ;
ReadOptions options = read_options_ ;
RandomGenerator gen ;
RandomGenerator gen ;
std : : string value ;
std : : string value ;
int64_t found = 0 ;
int64_t found = 0 ;
@ -7031,7 +7030,7 @@ class Benchmark {
// representing the existing value, we generate an array B of the same size,
// representing the existing value, we generate an array B of the same size,
// then compute C = A^B as C[i]=A[i]^B[i], and store C
// then compute C = A^B as C[i]=A[i]^B[i], and store C
void XORUpdateRandom ( ThreadState * thread ) {
void XORUpdateRandom ( ThreadState * thread ) {
ReadOptions options ( FLAGS_verify_checksum , true ) ;
ReadOptions options = read_options_ ;
RandomGenerator gen ;
RandomGenerator gen ;
std : : string existing_value ;
std : : string existing_value ;
int64_t found = 0 ;
int64_t found = 0 ;
@ -7096,7 +7095,7 @@ class Benchmark {
// Each operation causes the key grow by value_size (simulating an append).
// Each operation causes the key grow by value_size (simulating an append).
// Generally used for benchmarking against merges of similar type
// Generally used for benchmarking against merges of similar type
void AppendRandom ( ThreadState * thread ) {
void AppendRandom ( ThreadState * thread ) {
ReadOptions options ( FLAGS_verify_checksum , true ) ;
ReadOptions options = read_options_ ;
RandomGenerator gen ;
RandomGenerator gen ;
std : : string value ;
std : : string value ;
int64_t found = 0 ;
int64_t found = 0 ;
@ -7219,7 +7218,6 @@ class Benchmark {
// As with MergeRandom, the merge operator to use should be defined by
// As with MergeRandom, the merge operator to use should be defined by
// FLAGS_merge_operator.
// FLAGS_merge_operator.
void ReadRandomMergeRandom ( ThreadState * thread ) {
void ReadRandomMergeRandom ( ThreadState * thread ) {
ReadOptions options ( FLAGS_verify_checksum , true ) ;
RandomGenerator gen ;
RandomGenerator gen ;
std : : string value ;
std : : string value ;
int64_t num_hits = 0 ;
int64_t num_hits = 0 ;
@ -7246,7 +7244,7 @@ class Benchmark {
num_merges + + ;
num_merges + + ;
thread - > stats . FinishedOps ( nullptr , db , 1 , kMerge ) ;
thread - > stats . FinishedOps ( nullptr , db , 1 , kMerge ) ;
} else {
} else {
Status s = db - > Get ( options , key , & value ) ;
Status s = db - > Get ( read_ options_ , key , & value ) ;
if ( value . length ( ) > max_length )
if ( value . length ( ) > max_length )
max_length = value . length ( ) ;
max_length = value . length ( ) ;
@ -7277,8 +7275,7 @@ class Benchmark {
thread - > stats . Start ( thread - > tid ) ;
thread - > stats . Start ( thread - > tid ) ;
DB * db = SelectDB ( thread ) ;
DB * db = SelectDB ( thread ) ;
ReadOptions read_opts ( FLAGS_verify_checksum , true ) ;
ReadOptions read_opts = read_options_ ;
read_opts . adaptive_readahead = FLAGS_adaptive_readahead ;
std : : unique_ptr < char [ ] > ts_guard ;
std : : unique_ptr < char [ ] > ts_guard ;
Slice ts ;
Slice ts ;
if ( user_timestamp_size_ > 0 ) {
if ( user_timestamp_size_ > 0 ) {
@ -7418,9 +7415,7 @@ class Benchmark {
// RandomTransactionVerify() will then validate the correctness of the results
// RandomTransactionVerify() will then validate the correctness of the results
// by checking if the sum of all keys in each set is the same.
// by checking if the sum of all keys in each set is the same.
void RandomTransaction ( ThreadState * thread ) {
void RandomTransaction ( ThreadState * thread ) {
ReadOptions options ( FLAGS_verify_checksum , true ) ;
Duration duration ( FLAGS_duration , readwrites_ ) ;
Duration duration ( FLAGS_duration , readwrites_ ) ;
ReadOptions read_options ( FLAGS_verify_checksum , true ) ;
uint16_t num_prefix_ranges = static_cast < uint16_t > ( FLAGS_transaction_sets ) ;
uint16_t num_prefix_ranges = static_cast < uint16_t > ( FLAGS_transaction_sets ) ;
uint64_t transactions_done = 0 ;
uint64_t transactions_done = 0 ;
@ -7434,7 +7429,7 @@ class Benchmark {
txn_options . set_snapshot = FLAGS_transaction_set_snapshot ;
txn_options . set_snapshot = FLAGS_transaction_set_snapshot ;
RandomTransactionInserter inserter ( & thread - > rand , write_options_ ,
RandomTransactionInserter inserter ( & thread - > rand , write_options_ ,
read_options , FLAGS_num ,
read_options_ , FLAGS_num ,
num_prefix_ranges ) ;
num_prefix_ranges ) ;
if ( FLAGS_num_multi_db > 1 ) {
if ( FLAGS_num_multi_db > 1 ) {
@ -7585,7 +7580,6 @@ class Benchmark {
}
}
void TimeSeriesReadOrDelete ( ThreadState * thread , bool do_deletion ) {
void TimeSeriesReadOrDelete ( ThreadState * thread , bool do_deletion ) {
ReadOptions options ( FLAGS_verify_checksum , true ) ;
int64_t read = 0 ;
int64_t read = 0 ;
int64_t found = 0 ;
int64_t found = 0 ;
int64_t bytes = 0 ;
int64_t bytes = 0 ;
@ -7593,7 +7587,7 @@ class Benchmark {
Iterator * iter = nullptr ;
Iterator * iter = nullptr ;
// Only work on single database
// Only work on single database
assert ( db_ . db ! = nullptr ) ;
assert ( db_ . db ! = nullptr ) ;
iter = db_ . db - > NewIterator ( options ) ;
iter = db_ . db - > NewIterator ( read_ options_ ) ;
std : : unique_ptr < const char [ ] > key_guard ;
std : : unique_ptr < const char [ ] > key_guard ;
Slice key = AllocateKey ( & key_guard ) ;
Slice key = AllocateKey ( & key_guard ) ;
@ -7609,7 +7603,7 @@ class Benchmark {
}
}
if ( ! FLAGS_use_tailing_iterator ) {
if ( ! FLAGS_use_tailing_iterator ) {
delete iter ;
delete iter ;
iter = db_ . db - > NewIterator ( options ) ;
iter = db_ . db - > NewIterator ( read_ options_ ) ;
}
}
// Pick a Iterator to use
// Pick a Iterator to use