rocksdb/db/compaction
Changyu Bi d1ff401472 Delay bottommost level single file compactions (#11701)
Summary:
For leveled compaction, RocksDB has a special kind of compaction with reason "kBottommmostFiles" that compacts bottommost level files to clear data held by snapshots (more detail in https://github.com/facebook/rocksdb/issues/3009). Such compactions can happen soon after a relevant snapshot is released. For some use cases, a bottommost file may contain only a small amount of keys that can be cleared, so compacting such a file has a high write amp. In addition, these bottommost files may be compacted in compactions with reason other than "kBottommmostFiles" if we wait for some time (so that enough data is ingested to trigger such a compaction). This PR introduces an option `bottommost_file_compaction_delay` to specify the delay of these bottommost level single file compactions.

* The main change is in `VersionStorageInfo::ComputeBottommostFilesMarkedForCompaction()` where we only add a file to `bottommost_files_marked_for_compaction_` if it oldest_snapshot is larger than its non-zero largest_seqno **and** the file is old enough. Note that if a file is not old enough but its largest_seqno is less than oldest_snapshot, we exclude it from the calculation of `bottommost_files_mark_threshold_`. This makes the change simpler, but such a file's eligibility for compaction will only be checked the next time `ComputeBottommostFilesMarkedForCompaction()` is called. This happens when a new Version is created (compaction, flush, SetOptions()...), a new enough snapshot is released (`VersionStorageInfo::UpdateOldestSnapshot()`) or when a compaction is picked and compaction score has to be re-calculated.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/11701

Test Plan:
* Add two unit tests to test when bottommost_file_compaction_delay > 0.
* Ran crash test with the new option.

Reviewed By: jaykorean, ajkr

Differential Revision: D48331564

Pulled By: cbi42

fbshipit-source-id: c584f3dc5f6354fce3ed65f4c6366dc450b15ba8
2023-08-16 17:45:44 -07:00
..
clipping_iterator.h
clipping_iterator_test.cc
compaction.cc Compare the number of input keys and processed keys for compactions (#11571) 2023-07-28 09:47:31 -07:00
compaction.h Compare the number of input keys and processed keys for compactions (#11571) 2023-07-28 09:47:31 -07:00
compaction_iteration_stats.h
compaction_iterator.cc Compare the number of input keys and processed keys for compactions (#11571) 2023-07-28 09:47:31 -07:00
compaction_iterator.h Compare the number of input keys and processed keys for compactions (#11571) 2023-07-28 09:47:31 -07:00
compaction_iterator_test.cc Compare the number of input keys and processed keys for compactions (#11571) 2023-07-28 09:47:31 -07:00
compaction_job.cc Compare the number of input keys and processed keys for compactions (#11571) 2023-07-28 09:47:31 -07:00
compaction_job.h Compare the number of input keys and processed keys for compactions (#11571) 2023-07-28 09:47:31 -07:00
compaction_job_stats_test.cc Make option level_compaction_dynamic_level_bytes true by default (#11525) 2023-06-15 21:12:39 -07:00
compaction_job_test.cc Compare the number of input keys and processed keys for compactions (#11571) 2023-07-28 09:47:31 -07:00
compaction_outputs.cc Optimize about sstableKeyCompare (#11610) 2023-07-13 22:26:55 -07:00
compaction_outputs.h fix: std::optional value() build error on older macOS SDK (#11574) 2023-07-10 14:21:34 -07:00
compaction_picker.cc Do not include last level in compaction when allow_ingest_behind=true (#11489) 2023-06-14 11:28:56 -07:00
compaction_picker.h
compaction_picker_fifo.cc Support compacting files to different temperatures in FIFO compaction (#11428) 2023-05-11 16:40:59 -07:00
compaction_picker_fifo.h Support compacting files to different temperatures in FIFO compaction (#11428) 2023-05-11 16:40:59 -07:00
compaction_picker_level.cc Try to pick more files in LevelCompactionBuilder::TryExtendNonL0TrivialMove() (#11347) 2023-04-14 11:50:20 -07:00
compaction_picker_level.h
compaction_picker_test.cc Delay bottommost level single file compactions (#11701) 2023-08-16 17:45:44 -07:00
compaction_picker_universal.cc Do not include last level in compaction when allow_ingest_behind=true (#11489) 2023-06-14 11:28:56 -07:00
compaction_picker_universal.h
compaction_service_job.cc
compaction_service_test.cc Remove wait_unscheduled from waitForCompact internal API (#11443) 2023-05-17 18:13:50 -07:00
compaction_state.cc
compaction_state.h
file_pri.h Avoid shifting component too large error in FileTtlBooster (#11673) 2023-08-04 14:29:50 -07:00
sst_partitioner.cc
subcompaction_state.cc
subcompaction_state.h
tiered_compaction_test.cc Add WaitForCompact with WaitForCompactOptions to public API (#11436) 2023-05-25 17:25:51 -07:00