rocksdb/db/db_impl
Changyu Bi 43e9a60bb2 Always allow L0->L1 trivial move during manual compaction (#11375)
Summary:
during manual compaction (CompactRange()), L0->L1 trivial move is disabled when only L0 overlaps with compacting key range (introduced in https://github.com/facebook/rocksdb/issues/7368 to enforce kForce* contract). This can cause large memory usage due to compaction readahead when number of L0 files is large. This PR allows L0->L1 trivial move in this case, and will do a L1 -> L1 intra-level compaction when needed (`bottommost_level_compaction` is kForce*). In brief, consider a DB with only L0 file, and user calls CompactRange(kForce, nullptr, nullptr),
- before this PR, RocksDB does a L0 -> L1 compaction (disallow trivial move),
- after this PR, RocksDB does a L0 -> L1 compaction (allow trivial move), and a L1 -> L1 compaction.
Users can use kForceOptimized to avoid this extra L1->L1 compaction overhead when L0s are overlapping and cannot be trivial moved.

This PR also fixed a bug (see previous discussion in https://github.com/facebook/rocksdb/issues/11041) where `final_output_level` of a manual compaction can be miscalculated when `level_compaction_dynamic_level_bytes=true`. This bug could cause incorrect level being moved when CompactRangeOptions::change_level is specified.

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

Test Plan: - Added new unit tests to test that L0 -> L1 compaction allows trivial move and L1 -> L1 compaction is done when needed.

Reviewed By: ajkr

Differential Revision: D44943518

Pulled By: cbi42

fbshipit-source-id: e9fb770d17b163c18a623e1d1bd6b81159192708
2023-04-20 11:10:48 -07:00
..
compacted_db_impl.cc Remove RocksDB LITE (#11147) 2023-01-27 13:14:19 -08:00
compacted_db_impl.h Remove RocksDB LITE (#11147) 2023-01-27 13:14:19 -08:00
db_impl.cc Fix bug of prematurely excluded CF in atomic flush contains unflushed data that should've been included in the atomic flush (#11148) 2023-03-14 16:53:20 -07:00
db_impl.h Always allow L0->L1 trivial move during manual compaction (#11375) 2023-04-20 11:10:48 -07:00
db_impl_compaction_flush.cc Always allow L0->L1 trivial move during manual compaction (#11375) 2023-04-20 11:10:48 -07:00
db_impl_debug.cc Fix bug of prematurely excluded CF in atomic flush contains unflushed data that should've been included in the atomic flush (#11148) 2023-03-14 16:53:20 -07:00
db_impl_experimental.cc Remove RocksDB LITE (#11147) 2023-01-27 13:14:19 -08:00
db_impl_files.cc Simplify TEST_F(DBWALTest, FixSyncWalOnObseletedWalWithNewManifestCausingMissingWAL) (#11186) 2023-02-06 16:10:03 -08:00
db_impl_open.cc Drain unnecessary levels when level_compaction_dynamic_level_bytes=true (#11340) 2023-04-06 11:20:43 -07:00
db_impl_readonly.cc Remove RocksDB LITE (#11147) 2023-01-27 13:14:19 -08:00
db_impl_readonly.h Remove RocksDB LITE (#11147) 2023-01-27 13:14:19 -08:00
db_impl_secondary.cc Remove RocksDB LITE (#11147) 2023-01-27 13:14:19 -08:00
db_impl_secondary.h Remove RocksDB LITE (#11147) 2023-01-27 13:14:19 -08:00
db_impl_write.cc New stat rocksdb.{cf|db}-write-stall-stats exposed in a structural way (#11300) 2023-03-18 09:51:58 -07:00