rocksdb/test_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
..
fault_injection_test_env.cc Fix ingested file and direcotry not being sync (#5435) 2019-06-21 10:15:38 -07:00
fault_injection_test_env.h Fix ingested file and direcotry not being sync (#5435) 2019-06-21 10:15:38 -07:00
mock_time_env.h Move test related files under util/ to test_util/ (#5377) 2019-05-30 11:25:51 -07:00
sync_point_impl.cc Move test related files under util/ to test_util/ (#5377) 2019-05-30 11:25:51 -07:00
sync_point_impl.h Move test related files under util/ to test_util/ (#5377) 2019-05-30 11:25:51 -07:00
sync_point.cc Move test related files under util/ to test_util/ (#5377) 2019-05-30 11:25:51 -07:00
sync_point.h Move test related files under util/ to test_util/ (#5377) 2019-05-30 11:25:51 -07:00
testharness.cc Move test related files under util/ to test_util/ (#5377) 2019-05-30 11:25:51 -07:00
testharness.h Move test related files under util/ to test_util/ (#5377) 2019-05-30 11:25:51 -07:00
testutil.cc Add an option to put first key of each sst block in the index (#5289) 2019-06-24 20:54:04 -07:00
testutil.h Call ValidateOptions from SetOptions (#5368) 2019-06-03 19:49:57 -07:00
transaction_test_util.cc simplify include directive involving inttypes (#5402) 2019-06-06 13:56:07 -07:00
transaction_test_util.h Move test related files under util/ to test_util/ (#5377) 2019-05-30 11:25:51 -07:00