A library that provides an embeddable, persistent key-value store for fast storage. http://rocksdb.org
  • C++ 84.7%
  • Java 6.7%
  • Python 2.3%
  • C 2.3%
  • Starlark 1.7%
  • Other 2.2%
Find a file
Josh Kang d3285c483c Limit cache rebuilds from read-path range tombstone conversion (#15865)
Summary:
Pull Request resolved: https://github.com/meta/rocksdb/pull/15865

## Summary

With `min_tombstones_for_range_conversion` enabled, read-path conversions append logically redundant range tombstones to the active memtable. Invalidating the fragmented cache after every conversion can make concurrent scans contend on cache initialization and do quadratic rebuild work as the list grows.

Add the experimental mutable column family option `range_tombstone_conversion_cache_invalidation_threshold` with a default of 300. Column families that already enable read-path conversion pick up this threshold by default. Once the active memtable reaches that total range deletion count, conversions keep appending to the range deletion skiplist and leave the cache in place. The original point tombstones cover those deletions while the cache lags. Set the threshold to 0 to allow conversion-driven invalidation at any count. User-issued `DeleteRange` still invalidates the cache, and sealing the memtable fragments the full skiplist. SuperVersion installation applies the latest threshold to the active memtable, including when `SetOptions()` overlaps a memtable switch.

Deduplication probes up to five entries in the raw skiplist for a visible covering range. The probe includes conversions that left the cache in place and avoids loading the fragmented cache. The bounded search can miss a covering range, so deduplication is best effort.

The first conversion that skips invalidation marks the memtable for its lifetime. Subsequent external SST ingestion and bounded manual compaction overlap checks rebuild the marked memtable's cache from the skiplist, and later readers can reuse it. Memtables with no skipped invalidations use the normal cache path for overlap checks.

## Benchmarks

Compared optimized `db_bench` builds with and without the diff. Each trial ran 65,536 scans on a fresh tmpfs copy of a synthetic 1M-key database with clustered point deletions and an initially empty active memtable. Each scan creates an iterator, seeks to a random key, and makes up to 100 `Next()` calls. The table shows median throughput and median per-trial scan p99 over six interleaved trials per setting on an AMD EPYC 9D85 host.

| Setting | 1 thread scans/s | 1 thread p99 (µs) | 32 threads scans/s | 32 threads p99 (µs) | 64 threads scans/s | 64 threads p99 (µs) |
| Without diff | 34,276 | 209.2 | 239,422 | 544.7 | 316,418 | 688.7 |
| 100 | 31,866 | 102.5 | 462,608 | 161.3 | 737,108 | 193.2 |
| 200 | 32,399 | 100.2 | 487,837 | 158.1 | 783,200 | 212.3 |
| 300 | 32,884 | 97.2 | 489,082 | 157.6 | 810,475 | 186.0 |
| 400 | 33,216 | 95.0 | 504,642 | 159.7 | 814,232 | 189.9 |
| 500 | 33,600 | 92.9 | 511,258 | 160.7 | 769,692 | 202.2 |
| 1,000 | 35,344 | 91.6 | 530,512 | 170.4 | 733,838 | 232.3 |
| 2,000 | 35,400 | 151.8 | 416,102 | 335.7 | 547,294 | 361.2 |
| 3,000 | 34,154 | 204.3 | 259,013 | 523.4 | 329,258 | 576.4 |
| 0 (uncapped) | 34,520 | 204.8 | 261,318 | 519.1 | 333,020 | 574.6 |

Threshold 300 had the lowest median p99 at 32 and 64 threads. At one thread, throughput fell 4% versus the pre-diff build. Scans can step over more point tombstones once conversions stop invalidating the cache.

At 0, each successful conversion still invalidates the cache. The skiplist dedup check avoids a possible rebuild or wait during conversion, which likely helps throughput versus the pre-diff build. At 3,000, the workload stayed below the cutoff and tracked the uncapped setting.

Runs used the reverse-bytewise comparator and `min_tombstones_for_range_conversion=8`, with compression and automatic compaction disabled. Thresholds 2,000 and 3,000 ran alongside 300 in a separate sweep.

```bash
taskset -c 0-95 ./db_bench --db="$run" --options_file="$opts" \
  --benchmarks=memstats,seekrandom,memstats --num=1000000 --duration=0 \
  --threads="$threads" --reads="$((65536 / threads))" --seek_nexts=100 \
  --histogram=1 --use_existing_db=1 --seed=1 --reverse_iterator=0
```

Reviewed By: xingbowang

Differential Revision: D135421808

fbshipit-source-id: 19b5890f2c69debc8c878516affb967946540765
2026-12-02 16:23:00 -08:00
.github Remove GitHub-hosted AI code review workflows (#15781) 2026-11-25 09:41:48 -08:00
buckifier Add --table_factory_uri and a structured key-value mode (#15678) 2026-11-13 17:37:32 -08:00
build_tools Update for GitHub repository move to meta/rocksdb (#15508) 2026-10-28 17:23:50 -07:00
c_api_gen Limit cache rebuilds from read-path range tombstone conversion (#15865) 2026-12-02 16:23:00 -08:00
cache Initialize members flagged by pro-type-member-init (#15723) 2026-11-19 13:32:44 -08:00
claude_md Remove GitHub-hosted AI code review workflows (#15781) 2026-11-25 09:41:48 -08:00
cmake Refresh platform010 build dependencies and remove TBB (#14882) 2026-06-25 10:05:45 -07:00
coverage internal_repo_rocksdb 2024-10-14 03:01:20 -07:00
db Limit cache rebuilds from read-path range tombstone conversion (#15865) 2026-12-02 16:23:00 -08:00
db_stress_tool Limit cache rebuilds from read-path range tombstone conversion (#15865) 2026-12-02 16:23:00 -08:00
docs Fix Get() returning partial merges for keys split across SST files (#15746) 2026-11-20 10:48:15 -08:00
env Report FileSystem read-source attempts (#15732) 2026-12-01 17:45:57 -08:00
examples Use <cstdint> etc. instead of <stdint.h> etc. in C++ code (#15779) 2026-11-24 17:10:26 -08:00
file Preserve primary files during secondary purge and read-only open (#15867) 2026-12-02 15:20:26 -08:00
fuzz Update for GitHub repository move to meta/rocksdb (#15508) 2026-10-28 17:23:50 -07:00
githooks Fixes and enhancements to pre-push hook (#14680) 2026-04-28 15:56:32 -07:00
include/rocksdb Limit cache rebuilds from read-path range tombstone conversion (#15865) 2026-12-02 16:23:00 -08:00
java Limit cache rebuilds from read-path range tombstone conversion (#15865) 2026-12-02 16:23:00 -08:00
logging Use <cstdint> etc. instead of <stdint.h> etc. in C++ code (#15779) 2026-11-24 17:10:26 -08:00
memory Initialize members flagged by pro-type-member-init (#15723) 2026-11-19 13:32:44 -08:00
memtable Limit cache rebuilds from read-path range tombstone conversion (#15865) 2026-12-02 16:23:00 -08:00
microbench Remove dead code (#15407) 2026-10-30 15:45:12 -07:00
monitoring Initialize members flagged by pro-type-member-init (#15723) 2026-11-19 13:32:44 -08:00
options Limit cache rebuilds from read-path range tombstone conversion (#15865) 2026-12-02 16:23:00 -08:00
plugin Add initial CMake support to plugin (#9214) 2021-11-30 17:16:53 -08:00
port Use <cstdint> etc. instead of <stdint.h> etc. in C++ code (#15779) 2026-11-24 17:10:26 -08:00
table Prune out-of-bound data block and file loads in BlockBasedTableIterator and LevelIterator (#15842) 2026-12-02 13:18:45 -08:00
test_util Use <cstdint> etc. instead of <stdint.h> etc. in C++ code (#15779) 2026-11-24 17:10:26 -08:00
third-party Fix tests broken by gtest upgrade (#13661) 2025-06-04 10:44:17 -07:00
tools Limit cache rebuilds from read-path range tombstone conversion (#15865) 2026-12-02 16:23:00 -08:00
trace_replay Initialize members flagged by pro-type-member-init (#15723) 2026-11-19 13:32:44 -08:00
unreleased_history Limit cache rebuilds from read-path range tombstone conversion (#15865) 2026-12-02 16:23:00 -08:00
util Report FileSystem read-source attempts (#15732) 2026-12-01 17:45:57 -08:00
utilities Pass proximal output level to TableBuilderOptions for per-key placement outputs (#15795) 2026-11-30 11:53:55 -08:00
wiki Rename TableProperties::creation_time to oldest_ancestor_time (#15304) 2026-10-05 10:34:04 -07:00
.clang-format A script that automatically reformat affected lines 2014-01-14 12:21:24 -08:00
.clang-tidy 2026 02 21 accelerate ci (#14368) 2026-02-24 04:47:32 -08:00
.gitignore Improve build and test experience for Make builds (#14883) 2026-06-29 14:39:13 -07:00
.lgtm.yml Create lgtm.yml for LGTM.com C/C++ analysis (#4058) 2018-06-26 12:43:04 -07:00
.watchmanconfig Added .watchmanconfig file to rocksdb repo (#5593) 2019-07-19 15:00:33 -07:00
AGENTS.md db_stress: document expected-state trace/replay contract (#14612) 2026-04-14 09:58:20 -07:00
AUTHORS Update RocksDB Authors File 2017-10-18 14:42:10 -07:00
BUCK Add --table_factory_uri and a structured key-value mode (#15678) 2026-11-13 17:37:32 -08:00
ccache_msvc_compiler.bat Use ccache to accelerate windows build (#14064) 2025-10-20 10:37:08 -07:00
CLAUDE.md Copy FIFO temperature-change files without the DB mutex (#15497) 2026-11-17 19:09:26 -08:00
CMakeLists.txt Fix two flaky tests and add per-test ctest timeouts (#15695) 2026-11-16 11:51:26 -08:00
CODE_OF_CONDUCT.md Adopt Contributor Covenant 2019-08-29 23:21:01 -07:00
common.mk Clean up variables for temporary directory (#9961) 2022-05-06 16:38:06 -07:00
CONTRIBUTING.md Add Code of Conduct 2017-12-05 18:42:35 -08:00
COPYING Add GPLv2 as an alternative license. 2017-04-27 18:06:12 -07:00
crash_test.mk Add full external table support and crash testing (#15271) 2026-09-29 17:57:17 -07:00
DEFAULT_OPTIONS_HISTORY.md Add Options::DisableExtraChecks, clarify force_consistency_checks (#9363) 2022-01-18 17:31:03 -08:00
Directory.Build.props Use ccache to accelerate windows build (#14064) 2025-10-20 10:37:08 -07:00
DUMP_FORMAT.md First version of rocksdb_dump and rocksdb_undump. 2015-06-19 16:24:36 -07:00
folly.mk Fix libaio download after Folly update (#15404) 2026-10-14 18:25:57 -07:00
HISTORY.md Refresh RocksDB HISTORY for 11.15 release (#15776) 2026-11-24 13:49:58 -08:00
INSTALL.md Update for GitHub repository move to meta/rocksdb (#15508) 2026-10-28 17:23:50 -07:00
issue_template.md Add Google Group to Issue Template 2020-01-28 14:40:37 -08:00
LANGUAGE-BINDINGS.md Update for GitHub repository move to meta/rocksdb (#15508) 2026-10-28 17:23:50 -07:00
LICENSE.Apache Change RocksDB License 2017-07-15 16:11:23 -07:00
LICENSE.leveldb Add back the LevelDB license file 2017-07-16 18:42:18 -07:00
Makefile Add --table_factory_uri and a structured key-value mode (#15678) 2026-11-13 17:37:32 -08:00
PLUGINS.md Add encfs plugin link (#12070) 2023-11-14 07:33:21 -08:00
README.md Update for GitHub repository move to meta/rocksdb (#15508) 2026-10-28 17:23:50 -07:00
rocksdb.pc.in build: fix pkg-config file generation (#9953) 2022-05-30 12:46:40 -07:00
src.mk Add --table_factory_uri and a structured key-value mode (#15678) 2026-11-13 17:37:32 -08:00
thirdparty.inc Fix build jemalloc api (#5470) 2019-06-24 17:40:32 -07:00
USERS.md Add Venice as a RocksDB user (#13179) 2024-12-05 12:09:44 -08:00
Vagrantfile Adding CentOS 7 Vagrantfile & build script 2018-02-26 15:27:17 -08:00
WINDOWS_PORT.md Update branch name in WINDOWS_PORT.md (#8745) 2021-09-01 19:26:39 -07:00

RocksDB: A Persistent Key-Value Store for Flash and RAM Storage

RocksDB is developed and maintained by Facebook Database Engineering Team. It is built on earlier work on LevelDB by Sanjay Ghemawat (sanjay@google.com) and Jeff Dean (jeff@google.com)

This code is a library that forms the core building block for a fast key-value server, especially suited for storing data on flash drives. It has a Log-Structured-Merge-Database (LSM) design with flexible tradeoffs between Write-Amplification-Factor (WAF), Read-Amplification-Factor (RAF) and Space-Amplification-Factor (SAF). It has multi-threaded compactions, making it especially suitable for storing multiple terabytes of data in a single database.

Start with example usage here: https://github.com/meta/rocksdb/tree/main/examples

See the github wiki for more explanation.

The public interface is in include/. Callers should not include or rely on the details of any other header files in this package. Those internal APIs may be changed without warning.

Questions and discussions are welcome on the RocksDB Developers Public Facebook group and email list on Google Groups.

License

RocksDB is dual-licensed under both the GPLv2 (found in the COPYING file in the root directory) and Apache 2.0 License (found in the LICENSE.Apache file in the root directory). You may select, at your option, one of the above-listed licenses.