rocksdb/options
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
..
cf_options.cc simplify include directive involving inttypes (#5402) 2019-06-06 13:56:07 -07:00
cf_options.h Refresh snapshot list during long compactions (2nd attempt) (#5278) 2019-05-03 17:30:22 -07:00
db_options.cc Persistent Stats: persist stats history to disk (#5046) 2019-06-17 15:21:50 -07:00
db_options.h Persistent Stats: persist stats history to disk (#5046) 2019-06-17 15:21:50 -07:00
options_helper.cc Add an option to put first key of each sst block in the index (#5289) 2019-06-24 20:54:04 -07:00
options_helper.h Option string/map/file can set env from object registry (#5237) 2019-04-25 11:35:09 -07:00
options_parser.cc Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
options_parser.h Organizing rocksdb/table directory by format 2019-05-30 14:51:11 -07:00
options_sanity_check.cc Change RocksDB License 2017-07-15 16:11:23 -07:00
options_sanity_check.h Change RocksDB License 2017-07-15 16:11:23 -07:00
options_settable_test.cc Persistent Stats: persist stats history to disk (#5046) 2019-06-17 15:21:50 -07:00
options_test.cc Persistent Stats: persist stats history to disk (#5046) 2019-06-17 15:21:50 -07:00
options.cc Persistent Stats: persist stats history to disk (#5046) 2019-06-17 15:21:50 -07:00