Summary: readhotwriterandom now generates a certain number of keys randomly. This number is a percentage (determined by hotkeyspercentage) of --num. Then when a key is needed one of the keys in that list is chosen randomly.
Test Plan: Ran db_bench with small --num parameter to see if the keys are random and that we only use a subset of the "hot" keys.
Removed Cache from metrics flow for Block::MetricsIter to DBImpl
Summary:
Before this patch we had to send metrics to `Cache`, which then sent the metrics to `DBImpl`. Now we directly send them to `DBImpl`, by the use of a pointer to a pointer of a `BlockMetrics` instance. We can do this safely and without additional locks because:
* `Block::MetricsIter` runs in the same thread as `DBImpl::Get()` (in which the `BlockMetrics` pointer resides)
* `DBImpl::Get()` locks `DBImpl` again after the `Block::MetricsIter` is destroyed, so we don't have to do an additional lock.
Hotcold: Added ability to select which levels record metrics
Summary: Added an option to `Options` to specify which levels have metrics recorded and used that option in `Version::Get()` to stop metrics being recorded for wrong levels and in `DBImpl` to stop `DoCompactionWork()` trying to split on hotcold for levels where no metrics are available.
Hotcold: Removed Table from metrics flow path and now only create BlockMetrics in Block::MetricsIter
Summary: Metrics no longer pass through `Table` to the cache and instead go directly from `Block::MetricsIter`. Additionally `BlockMetrics` is now only created when a `Seek()` is performed.
Hotcold: Short circuiting behaviour for file lookups when finding key in hot file
Summary:
Before this update both hot and cold file had to be queried in order to get the latest value for a given key. Now if the key is found in the hot file then we know the latest value is in the hot file.
Changed compaction to not allow a user key to have a record with a smaller sequence number in the hot file if there is a record with a larger sequence number in the cold file.
Added short circuiting to `Version::Get()` to assume that if a key is found in a newer file then it has a newer sequence number.
Test Plan:
`make check`
ran `db_bench` compiled with assertions on and in hot cold mode.
Hotcold: Changing compaction based on hotness of record.
Summary:
Changed `DoCompactionWork()` to output multiple files and imported https://reviews.facebook.net/D8025 (Ideally all issues with version_set.h, version_set.cc and version_set_test.cc should be brought up there so I can keep that patch up to date and we can decide whether to mainline it separately) so we can handle overlapping files in level 1+.
Added code to determine whether a record is hot or cold given the metrics DB and an iterator on the database (which allows us to get all the necessary data in order to lookup the hotness)