@ -47,6 +47,8 @@ DEFINE_string(benchmarks,
" overwrite, "
" overwrite, "
" readrandom, "
" readrandom, "
" readrandom, "
" readrandom, "
" newiterator, "
" newiteratorwhilewriting, "
" readseq, "
" readseq, "
" readreverse, "
" readreverse, "
" compact, "
" compact, "
@ -1172,6 +1174,9 @@ class Benchmark {
method = & Benchmark : : ReadRandom ;
method = & Benchmark : : ReadRandom ;
} else if ( name = = Slice ( " newiterator " ) ) {
} else if ( name = = Slice ( " newiterator " ) ) {
method = & Benchmark : : IteratorCreation ;
method = & Benchmark : : IteratorCreation ;
} else if ( name = = Slice ( " newiteratorwhilewriting " ) ) {
num_threads + + ; // Add extra thread for writing
method = & Benchmark : : IteratorCreationWhileWriting ;
} else if ( name = = Slice ( " seekrandom " ) ) {
} else if ( name = = Slice ( " seekrandom " ) ) {
method = & Benchmark : : SeekRandom ;
method = & Benchmark : : SeekRandom ;
} else if ( name = = Slice ( " readrandomsmall " ) ) {
} else if ( name = = Slice ( " readrandomsmall " ) ) {
@ -1864,6 +1869,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 ( FLAGS_verify_checksum , true ) ;
options . prefix_seek = ( FLAGS_prefix_size > 0 ) ;
while ( ! duration . Done ( 1 ) ) {
while ( ! duration . Done ( 1 ) ) {
Iterator * iter = db_ - > NewIterator ( options ) ;
Iterator * iter = db_ - > NewIterator ( options ) ;
delete iter ;
delete iter ;
@ -1871,6 +1877,14 @@ class Benchmark {
}
}
}
}
void IteratorCreationWhileWriting ( ThreadState * thread ) {
if ( thread - > tid > 0 ) {
IteratorCreation ( thread ) ;
} else {
BGWriter ( thread ) ;
}
}
void SeekRandom ( ThreadState * thread ) {
void SeekRandom ( ThreadState * thread ) {
int64_t read = 0 ;
int64_t read = 0 ;
int64_t found = 0 ;
int64_t found = 0 ;
@ -1934,6 +1948,11 @@ class Benchmark {
if ( thread - > tid > 0 ) {
if ( thread - > tid > 0 ) {
ReadRandom ( thread ) ;
ReadRandom ( thread ) ;
} else {
} else {
BGWriter ( thread ) ;
}
}
void BGWriter ( ThreadState * thread ) {
// Special thread that keeps writing until other threads are done.
// Special thread that keeps writing until other threads are done.
RandomGenerator gen ;
RandomGenerator gen ;
double last = FLAGS_env - > NowMicros ( ) ;
double last = FLAGS_env - > NowMicros ( ) ;
@ -1984,7 +2003,6 @@ class Benchmark {
}
}
}
}
}
}
}
// Given a key K and value V, this puts (K+"0", V), (K+"1", V), (K+"2", V)
// Given a key K and value V, this puts (K+"0", V), (K+"1", V), (K+"2", V)
// in DB atomically i.e in a single batch. Also refer GetMany.
// in DB atomically i.e in a single batch. Also refer GetMany.