Skip to content

Commit

Permalink
Merge branch 'master' into zaidoon/make-cf-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
zaidoon1 authored Mar 21, 2024
2 parents c4124d7 + fb73945 commit c7180e0
Show file tree
Hide file tree
Showing 10 changed files with 237 additions and 146 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rust-rocksdb"
description = "Rust wrapper for Facebook's RocksDB embeddable database"
version = "0.22.7"
version = "0.23.0"
edition = "2021"
rust-version = "1.75.0"
authors = [
Expand Down Expand Up @@ -29,13 +29,14 @@ zstd = ["rust-librocksdb-sys/zstd"]
zlib = ["rust-librocksdb-sys/zlib"]
bzip2 = ["rust-librocksdb-sys/bzip2"]
rtti = ["rust-librocksdb-sys/rtti"]
mt_static = ["rust-librocksdb-sys/mt_static"]
multi-threaded-cf = []
serde1 = ["serde"]
malloc-usable-size = ["rust-librocksdb-sys/malloc-usable-size"]

[dependencies]
libc = "0.2"
rust-librocksdb-sys = { path = "librocksdb-sys", version = "0.18.1" }
rust-librocksdb-sys = { path = "librocksdb-sys", version = "0.19.0" }
serde = { version = "1", features = ["derive"], optional = true }

[dev-dependencies]
Expand Down
3 changes: 2 additions & 1 deletion librocksdb-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rust-librocksdb-sys"
version = "0.18.1+8.11.3"
version = "0.19.0+9.0.0"
edition = "2021"
rust-version = "1.75.0"
authors = [
Expand Down Expand Up @@ -31,6 +31,7 @@ exclude = [
default = ["static"]
jemalloc = ["tikv-jemalloc-sys"]
static = ["libz-sys?/static", "bzip2-sys?/static"]
mt_static = []
io-uring = ["pkg-config"]
snappy = []
lz4 = ["lz4-sys"]
Expand Down
6 changes: 6 additions & 0 deletions librocksdb-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ fn build_rocksdb() {
}

if target.contains("msvc") {
if cfg!(feature = "mt_static") {
config.static_crt(true);
}
config.flag("-EHsc");
config.flag("-std:c++17");
} else {
Expand Down Expand Up @@ -283,6 +286,9 @@ fn build_snappy() {

if target.contains("msvc") {
config.flag("-EHsc");
if cfg!(feature = "mt_static") {
config.static_crt(true);
}
} else {
// Snappy requires C++11.
// See: https://github.com/google/snappy/blob/master/CMakeLists.txt#L32-L38
Expand Down
8 changes: 4 additions & 4 deletions librocksdb-sys/build_version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@

// The build script may replace these values with real values based
// on whether or not GIT is available and the platform settings
static const std::string rocksdb_build_git_sha = "c2467b141e840fdba5b3a1810763043e56449fb9";
static const std::string rocksdb_build_git_tag = "rocksdb_build_git_tag:v8.11.3";
static const std::string rocksdb_build_git_sha = "f4441966592636253fd5ab0bb9ed44fc2697fc53";
static const std::string rocksdb_build_git_tag = "rocksdb_build_git_tag:v9.0.0";
#define HAS_GIT_CHANGES 0
#if HAS_GIT_CHANGES == 0
// If HAS_GIT_CHANGES is 0, the GIT date is used.
// Use the time the branch/tag was last modified
static const std::string rocksdb_build_date = "rocksdb_build_date:2024-02-27 16:24:11";
static const std::string rocksdb_build_date = "rocksdb_build_date:2024-03-18 15:15:28";
#else
// If HAS_GIT_CHANGES is > 0, the branch/tag has modifications.
// Use the time the build was created.
static const std::string rocksdb_build_date = "rocksdb_build_date:2024-02-27 16:24:11";
static const std::string rocksdb_build_date = "rocksdb_build_date:2024-03-18 15:15:28";
#endif

std::unordered_map<std::string, ROCKSDB_NAMESPACE::RegistrarFunc> ROCKSDB_NAMESPACE::ObjectRegistry::builtins_ = {};
Expand Down
2 changes: 1 addition & 1 deletion librocksdb-sys/rocksdb
Submodule rocksdb updated 511 files
84 changes: 65 additions & 19 deletions src/db_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ impl BlockBasedOptions {
/// See full [list](https://github.com/facebook/rocksdb/blob/v8.6.7/include/rocksdb/table.h#L493-L521)
/// of the supported versions.
///
/// Default: 5.
/// Default: 6.
pub fn set_format_version(&mut self, version: i32) {
unsafe {
ffi::rocksdb_block_based_options_set_format_version(self.inner, version);
Expand Down Expand Up @@ -2886,17 +2886,6 @@ impl Options {
}
}

/// Specifies the file access pattern once a compaction is started.
///
/// It will be applied to all input files of a compaction.
///
/// Default: Normal
pub fn set_access_hint_on_compaction_start(&mut self, pattern: AccessHint) {
unsafe {
ffi::rocksdb_options_set_access_hint_on_compaction_start(self.inner, pattern as c_int);
}
}

/// Enable/disable adaptive mutex, which spins in the user space before resorting to kernel.
///
/// This could reduce context switch when the mutex is not
Expand Down Expand Up @@ -3165,6 +3154,55 @@ impl Options {
}
}

/// Create a RateLimiter object, which can be shared among RocksDB instances to
/// control write rate of flush and compaction.
///
/// rate_bytes_per_sec: this is the only parameter you want to set most of the
/// time. It controls the total write rate of compaction and flush in bytes per
/// second. Currently, RocksDB does not enforce rate limit for anything other
/// than flush and compaction, e.g. write to WAL.
///
/// refill_period_us: this controls how often tokens are refilled. For example,
/// when rate_bytes_per_sec is set to 10MB/s and refill_period_us is set to
/// 100ms, then 1MB is refilled every 100ms internally. Larger value can lead to
/// burstier writes while smaller value introduces more CPU overhead.
/// The default should work for most cases.
///
/// fairness: RateLimiter accepts high-pri requests and low-pri requests.
/// A low-pri request is usually blocked in favor of hi-pri request. Currently,
/// RocksDB assigns low-pri to request from compaction and high-pri to request
/// from flush. Low-pri requests can get blocked if flush requests come in
/// continuously. This fairness parameter grants low-pri requests permission by
/// 1/fairness chance even though high-pri requests exist to avoid starvation.
/// You should be good by leaving it at default 10.
///
/// mode: Mode indicates which types of operations count against the limit.
///
/// auto_tuned: Enables dynamic adjustment of rate limit within the range
/// `[rate_bytes_per_sec / 20, rate_bytes_per_sec]`, according to
/// the recent demand for background I/O.
pub fn set_ratelimiter_with_mode(
&mut self,
rate_bytes_per_sec: i64,
refill_period_us: i64,
fairness: i32,
mode: RateLimiterMode,
auto_tuned: bool,
) {
unsafe {
let ratelimiter = ffi::rocksdb_ratelimiter_create_with_mode(
rate_bytes_per_sec,
refill_period_us,
fairness,
mode as c_int,
auto_tuned,
);
// Since limiter is wrapped in shared_ptr, we don't need to
// call rocksdb_ratelimiter_destroy explicitly.
ffi::rocksdb_options_set_ratelimiter(self.inner, ratelimiter);
}
}

/// Sets the maximal size of the info log file.
///
/// If the log file is larger than `max_log_file_size`, a new info log file
Expand Down Expand Up @@ -3222,6 +3260,17 @@ impl Options {
}
}

/// Prints logs to stderr for faster debugging
/// See official [wiki](https://github.com/facebook/rocksdb/wiki/Logger) for more information.
pub fn set_stderr_logger(&mut self, log_level: LogLevel, prefix: impl CStrLike) {
let p = prefix.into_c_string().unwrap();

unsafe {
let logger = ffi::rocksdb_logger_create_stderr_logger(log_level as c_int, p.as_ptr());
ffi::rocksdb_options_set_info_log(self.inner, logger);
}
}

/// Sets the threshold at which all writes will be slowed down to at least delayed_write_rate if estimated
/// bytes needed to be compaction exceed this threshold.
///
Expand Down Expand Up @@ -4047,15 +4096,12 @@ pub enum DBRecoveryMode {
SkipAnyCorruptedRecord = ffi::rocksdb_skip_any_corrupted_records_recovery as isize,
}

/// File access pattern once a compaction has started
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
#[repr(i32)]
pub enum AccessHint {
None = 0,
Normal,
Sequential,
WillNeed,
pub enum RateLimiterMode {
KReadsOnly = 0,
KWritesOnly = 1,
KAllIo = 2,
}

pub struct FifoCompactOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub use crate::{
CompactOptions, CuckooTableOptions, DBCompactionStyle, DBCompressionType, DBPath,
DBRecoveryMode, DataBlockIndexType, FifoCompactOptions, FlushOptions,
IngestExternalFileOptions, KeyEncodingType, LogLevel, MemtableFactory, Options,
PlainTableFactoryOptions, ReadOptions, ReadTier, UniversalCompactOptions,
PlainTableFactoryOptions, RateLimiterMode, ReadOptions, ReadTier, UniversalCompactOptions,
UniversalCompactionStopStyle, WaitForCompactOptions, WriteBufferManager, WriteOptions,
},
db_pinnable_slice::DBPinnableSlice,
Expand Down
Loading

0 comments on commit c7180e0

Please sign in to comment.