Skip to content

Commit 1560bb9

Browse files
committed
Readrandom with tailing iterator
Summary: Added an option for readrandom benchmark to run with tailing iterator instead of Get. Benefit of tailing iterator is that it doesn't require locking DB mutex on access. I also have some results when running on my machine. The results highly depend on number of cache shards. With our current benchmark setting of 4 table cache shards and 6 block cache shards, I don't see much improvements of using tailing iterator. In that case, we're probably seeing cache mutex contention. Here are the results for different number of shards cache shards tailing iterator get 6 1.38M 1.16M 10 1.58M 1.15M As soon as we get rid of cache mutex contention, we're seeing big improvements in using tailing iterator vs. ordinary get. Test Plan: ran regression test Reviewers: dhruba, haobo, ljin, kailiu, sding Reviewed By: haobo CC: tnovak Differential Revision: https://reviews.facebook.net/D15867
1 parent d53b188 commit 1560bb9

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

build_tools/regression_build_test.sh

+22
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,27 @@ make release
117117
--sync=0 \
118118
--threads=16 > ${STAT_FILE}.readrandom
119119

120+
# measure readrandom with 6GB block cache and tailing iterator
121+
./db_bench \
122+
--benchmarks=readrandom \
123+
--db=$DATA_DIR \
124+
--use_existing_db=1 \
125+
--bloom_bits=10 \
126+
--num=$NUM \
127+
--reads=$((NUM / 5)) \
128+
--cache_size=6442450944 \
129+
--cache_numshardbits=6 \
130+
--table_cache_numshardbits=4 \
131+
--open_files=55000 \
132+
--disable_seek_compaction=1 \
133+
--use_tailing_iterator=1 \
134+
--statistics=1 \
135+
--histogram=1 \
136+
--disable_data_sync=1 \
137+
--disable_wal=1 \
138+
--sync=0 \
139+
--threads=16 > ${STAT_FILE}.readrandomtailing
140+
120141
# measure readrandom with 100MB block cache
121142
./db_bench \
122143
--benchmarks=readrandom \
@@ -300,6 +321,7 @@ function send_benchmark_to_ods {
300321
send_benchmark_to_ods overwrite overwrite $STAT_FILE.overwrite
301322
send_benchmark_to_ods fillseq fillseq $STAT_FILE.fillseq
302323
send_benchmark_to_ods readrandom readrandom $STAT_FILE.readrandom
324+
send_benchmark_to_ods readrandom readrandom_tailing $STAT_FILE.readrandomtailing
303325
send_benchmark_to_ods readrandom readrandom_smallblockcache $STAT_FILE.readrandomsmallblockcache
304326
send_benchmark_to_ods readrandom readrandom_memtable_sst $STAT_FILE.readrandom_mem_sst
305327
send_benchmark_to_ods readrandom readrandom_fillunique_random $STAT_FILE.readrandom_filluniquerandom

db/db_bench.cc

+18
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ static auto FLAGS_compaction_fadvice_e =
447447
DEFINE_bool(use_multiget, false,
448448
"Use multiget to access a series of keys instead of get");
449449

450+
DEFINE_bool(use_tailing_iterator, false,
451+
"Use tailing iterator to access a series of keys instead of get");
452+
450453
DEFINE_int64(keys_per_multiget, 90, "If use_multiget is true, determines number"
451454
" of keys to group per call Arbitrary default is good because it"
452455
" agrees with readwritepercent");
@@ -1729,6 +1732,21 @@ class Benchmark {
17291732
thread->stats.FinishedSingleOp(db_);
17301733
keys_left -= num_keys;
17311734
}
1735+
} else if (FLAGS_use_tailing_iterator) { // use tailing iterator for gets
1736+
options.tailing = true;
1737+
Iterator* iter = db_->NewIterator(options);
1738+
while (!duration.Done(1)) {
1739+
const long long k = thread->rand.Next() % FLAGS_num;
1740+
unique_ptr<char[]> key = GenerateKeyFromInt(k);
1741+
1742+
iter->Seek(key.get());
1743+
if (iter->Valid() && iter->key().compare(Slice(key.get())) == 0) {
1744+
++found;
1745+
}
1746+
1747+
thread->stats.FinishedSingleOp(db_);
1748+
}
1749+
delete iter;
17321750
} else { // Regular case. Do one "get" at a time Get
17331751
Iterator* iter = db_->NewIterator(options);
17341752
std::string value;

0 commit comments

Comments
 (0)