b4d7209428
Summary: The first key is used to defer reading the data block until this file gets to the top of merging iterator's heap. For short range scans, most files never make it to the top of the heap, so this change can reduce read amplification by a lot sometimes. Consider the following workload. There are a few data streams (we'll be calling them "logs"), each stream consisting of a sequence of blobs (we'll be calling them "records"). Each record is identified by log ID and a sequence number within the log. RocksDB key is concatenation of log ID and sequence number (big endian). Reads are mostly relatively short range scans, each within a single log. Writes are mostly sequential for each log, but writes to different logs are randomly interleaved. Compactions are disabled; instead, when we accumulate a few tens of sst files, we create a new column family and start writing to it. So, a typical sst file consists of a few ranges of blocks, each range corresponding to one log ID (we use FlushBlockPolicy to cut blocks at log boundaries). A typical read would go like this. First, iterator Seek() reads one block from each sst file. Then a series of Next()s move through one sst file (since writes to each log are mostly sequential) until the subiterator reaches the end of this log in this sst file; then Next() switches to the next sst file and reads sequentially from that, and so on. Often a range scan will only return records from a small number of blocks in small number of sst files; in this case, the cost of initial Seek() reading one block from each file may be bigger than the cost of reading the actually useful blocks. Neither iterate_upper_bound nor bloom filters can prevent reading one block from each file in Seek(). But this PR can: if the index contains first key from each block, we don't have to read the block until this block actually makes it to the top of merging iterator's heap, so for short range scans we won't read any blocks from most of the sst files. This PR does the deferred block loading inside value() call. This is not ideal: there's no good way to report an IO error from inside value(). As discussed with siying offline, it would probably be better to change InternalIterator's interface to explicitly fetch deferred value and get status. I'll do it in a separate PR. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5289 Differential Revision: D15256423 Pulled By: al13n321 fbshipit-source-id: 750e4c39ce88e8d41662f701cf6275d9388ba46a |
||
---|---|---|
.. | ||
backupablejni.cc | ||
backupenginejni.cc | ||
cassandra_compactionfilterjni.cc | ||
cassandra_value_operator.cc | ||
checkpoint.cc | ||
clock_cache.cc | ||
columnfamilyhandle.cc | ||
compact_range_options.cc | ||
compaction_filter_factory_jnicallback.cc | ||
compaction_filter_factory_jnicallback.h | ||
compaction_filter_factory.cc | ||
compaction_filter.cc | ||
compaction_job_info.cc | ||
compaction_job_stats.cc | ||
compaction_options_fifo.cc | ||
compaction_options_universal.cc | ||
compaction_options.cc | ||
comparator.cc | ||
comparatorjnicallback.cc | ||
comparatorjnicallback.h | ||
compression_options.cc | ||
env_options.cc | ||
env.cc | ||
filter.cc | ||
ingest_external_file_options.cc | ||
iterator.cc | ||
jnicallback.cc | ||
jnicallback.h | ||
loggerjnicallback.cc | ||
loggerjnicallback.h | ||
lru_cache.cc | ||
memory_util.cc | ||
memtablejni.cc | ||
merge_operator.cc | ||
native_comparator_wrapper_test.cc | ||
optimistic_transaction_db.cc | ||
optimistic_transaction_options.cc | ||
options_util.cc | ||
options.cc | ||
persistent_cache.cc | ||
portal.h | ||
ratelimiterjni.cc | ||
remove_emptyvalue_compactionfilterjni.cc | ||
restorejni.cc | ||
rocks_callback_object.cc | ||
rocksdb_exception_test.cc | ||
rocksjni.cc | ||
slice.cc | ||
snapshot.cc | ||
sst_file_manager.cc | ||
sst_file_writerjni.cc | ||
statistics.cc | ||
statisticsjni.cc | ||
statisticsjni.h | ||
table_filter_jnicallback.cc | ||
table_filter_jnicallback.h | ||
table_filter.cc | ||
table.cc | ||
thread_status.cc | ||
trace_writer_jnicallback.cc | ||
trace_writer_jnicallback.h | ||
trace_writer.cc | ||
transaction_db_options.cc | ||
transaction_db.cc | ||
transaction_log.cc | ||
transaction_notifier_jnicallback.cc | ||
transaction_notifier_jnicallback.h | ||
transaction_notifier.cc | ||
transaction_options.cc | ||
transaction.cc | ||
ttl.cc | ||
wal_filter_jnicallback.cc | ||
wal_filter_jnicallback.h | ||
wal_filter.cc | ||
write_batch_test.cc | ||
write_batch_with_index.cc | ||
write_batch.cc | ||
write_buffer_manager.cc | ||
writebatchhandlerjnicallback.cc | ||
writebatchhandlerjnicallback.h |