@ -46,9 +46,10 @@ DEFINE_string(benchmarks,
" fillrandom, "
" fillrandom, "
" overwrite, "
" overwrite, "
" readrandom, "
" readrandom, "
" readrandom, "
" newiterator, "
" newiterator, "
" newiteratorwhilewriting, "
" newiteratorwhilewriting, "
" seekrandom, "
" seekrandomwhilewriting, "
" readseq, "
" readseq, "
" readreverse, "
" readreverse, "
" compact, "
" compact, "
@ -104,6 +105,7 @@ DEFINE_string(benchmarks,
" operations. Must be used with merge_operator \n "
" operations. Must be used with merge_operator \n "
" \t newiterator -- repeated iterator creation \n "
" \t newiterator -- repeated iterator creation \n "
" \t seekrandom -- N random seeks \n "
" \t seekrandom -- N random seeks \n "
" \t seekrandom -- 1 writer, N threads doing random seeks \n "
" \t crc32c -- repeated crc32c of 4K of data \n "
" \t crc32c -- repeated crc32c of 4K of data \n "
" \t acquireload -- load N*1000 times \n "
" \t acquireload -- load N*1000 times \n "
" Meta operations: \n "
" Meta operations: \n "
@ -1179,6 +1181,9 @@ class Benchmark {
method = & Benchmark : : IteratorCreationWhileWriting ;
method = & Benchmark : : IteratorCreationWhileWriting ;
} else if ( name = = Slice ( " seekrandom " ) ) {
} else if ( name = = Slice ( " seekrandom " ) ) {
method = & Benchmark : : SeekRandom ;
method = & Benchmark : : SeekRandom ;
} else if ( name = = Slice ( " seekrandomwhilewriting " ) ) {
num_threads + + ; // Add extra thread for writing
method = & Benchmark : : SeekRandomWhileWriting ;
} else if ( name = = Slice ( " readrandomsmall " ) ) {
} else if ( name = = Slice ( " readrandomsmall " ) ) {
reads_ / = 1000 ;
reads_ / = 1000 ;
method = & Benchmark : : ReadRandom ;
method = & Benchmark : : ReadRandom ;
@ -1890,6 +1895,7 @@ class Benchmark {
int64_t found = 0 ;
int64_t found = 0 ;
ReadOptions options ( FLAGS_verify_checksum , true ) ;
ReadOptions options ( FLAGS_verify_checksum , true ) ;
options . tailing = FLAGS_use_tailing_iterator ;
options . tailing = FLAGS_use_tailing_iterator ;
options . prefix_seek = ( FLAGS_prefix_size > 0 ) ;
auto * iter = db_ - > NewIterator ( options ) ;
auto * iter = db_ - > NewIterator ( options ) ;
Slice key = AllocateKey ( ) ;
Slice key = AllocateKey ( ) ;
std : : unique_ptr < const char [ ] > key_guard ( key . data ( ) ) ;
std : : unique_ptr < const char [ ] > key_guard ( key . data ( ) ) ;
@ -1912,6 +1918,14 @@ class Benchmark {
thread - > stats . AddMessage ( msg ) ;
thread - > stats . AddMessage ( msg ) ;
}
}
void SeekRandomWhileWriting ( ThreadState * thread ) {
if ( thread - > tid > 0 ) {
SeekRandom ( thread ) ;
} else {
BGWriter ( thread ) ;
}
}
void DoDelete ( ThreadState * thread , bool seq ) {
void DoDelete ( ThreadState * thread , bool seq ) {
WriteBatch batch ;
WriteBatch batch ;
Duration duration ( seq ? 0 : FLAGS_duration , num_ ) ;
Duration duration ( seq ? 0 : FLAGS_duration , num_ ) ;