rocksdb/util
Mike Kolupaev b4d7209428 Add an option to put first key of each sst block in the index (#5289)
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
2019-06-24 20:54:04 -07:00
..
aligned_buffer.h Document AlignedBuffer (#5345) 2019-05-24 10:05:40 -07:00
autovector.h
autovector_test.cc Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
bloom.cc Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
bloom_test.cc Move some logging related files to logging/ (#5387) 2019-05-31 17:23:59 -07:00
build_version.cc.in
build_version.h
cast_util.h
channel.h
coding.cc
coding.h Add an option to put first key of each sst block in the index (#5289) 2019-06-24 20:54:04 -07:00
coding_test.cc Move test related files under util/ to test_util/ (#5377) 2019-05-30 11:25:51 -07:00
compaction_job_stats_impl.cc Refresh snapshot list during long compactions (2nd attempt) (#5278) 2019-05-03 17:30:22 -07:00
comparator.cc Add support for timestamp in Get/Put (#5079) 2019-06-05 23:10:47 -07:00
compression.h Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
compression_context_cache.cc
compression_context_cache.h
concurrent_task_limiter_impl.cc
concurrent_task_limiter_impl.h
core_local.h
crc32c.cc RocksDB CRC32c optimization with ARMv8 Intrinsic (#5221) 2019-04-30 10:59:05 -07:00
crc32c.h
crc32c_arm64.cc RocksDB CRC32c optimization with ARMv8 Intrinsic (#5221) 2019-04-30 10:59:05 -07:00
crc32c_arm64.h simplify include directive involving inttypes (#5402) 2019-06-06 13:56:07 -07:00
crc32c_ppc.c C file should not include <cinttypes>, it is a C++ header. (#5499) 2019-06-24 16:12:39 -07:00
crc32c_ppc.h Remove PATENTS text from a few straggler files (#5326) 2019-05-21 16:22:35 -07:00
crc32c_ppc_asm.S Remove PATENTS text from a few straggler files (#5326) 2019-05-21 16:22:35 -07:00
crc32c_ppc_constants.h Remove PATENTS text from a few straggler files (#5326) 2019-05-21 16:22:35 -07:00
crc32c_test.cc Move test related files under util/ to test_util/ (#5377) 2019-05-30 11:25:51 -07:00
duplicate_detector.h simplify include directive involving inttypes (#5402) 2019-06-06 13:56:07 -07:00
dynamic_bloom.cc Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
dynamic_bloom.h
dynamic_bloom_test.cc simplify include directive involving inttypes (#5402) 2019-06-06 13:56:07 -07:00
file_reader_writer.cc Compaction Reads should read no more than compaction_readahead_size bytes, when set! (#5498) 2019-06-21 21:31:49 -07:00
file_reader_writer.h Combine the read-ahead logic for user reads and compaction reads (#5431) 2019-06-19 14:10:46 -07:00
file_reader_writer_test.cc Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
filelock_test.cc Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
filter_policy.cc
gflags_compat.h
hash.cc
hash.h
hash_map.h
hash_test.cc Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
heap.h
heap_test.cc
kv_map.h
log_write_bench.cc util: fix log_write_bench (#5335) 2019-05-31 17:17:57 -07:00
murmurhash.cc
murmurhash.h
mutexlock.h
ppc-opcode.h Remove PATENTS text from a few straggler files (#5326) 2019-05-21 16:22:35 -07:00
random.cc
random.h
rate_limiter.cc Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
rate_limiter.h
rate_limiter_test.cc simplify include directive involving inttypes (#5402) 2019-06-06 13:56:07 -07:00
repeatable_thread.h Move test related files under util/ to test_util/ (#5377) 2019-05-30 11:25:51 -07:00
repeatable_thread_test.cc Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
set_comparator.h
slice.cc
slice_transform_test.cc Move test related files under util/ to test_util/ (#5377) 2019-05-30 11:25:51 -07:00
status.cc Use separate status code for column family drop and db shutdown in progress (#5275) 2019-05-20 10:47:32 -07:00
stderr_logger.h
stop_watch.h
string_util.cc simplify include directive involving inttypes (#5402) 2019-06-06 13:56:07 -07:00
string_util.h
thread_list_test.cc Move test related files under util/ to test_util/ (#5377) 2019-05-30 11:25:51 -07:00
thread_local.cc
thread_local.h
thread_local_test.cc Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
thread_operation.h
threadpool_imp.cc
threadpool_imp.h
timer_queue.h Move test related files under util/ to test_util/ (#5377) 2019-05-30 11:25:51 -07:00
timer_queue_test.cc
user_comparator_wrapper.h
util.h
vector_iterator.h
xxhash.cc
xxhash.h