From d0c081d0025e50c40b6e21d8f98afaad87726e02 Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Tue, 31 Dec 2024 22:44:52 +0100 Subject: [PATCH] chore: update rocksdb dependency to 0.22 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updating rocksdb to 0.22 allows us to remove the run-time CStr → str conversion when collecting statistics. rocksdb is at 0.23 however I got dependency resolution failure when trying to update to that version (included below). Since 0.22 is enough to resolve one of my TODOs, my job here is done. ;) error: failed to select a version for `tikv-jemalloc-sys`. ... required by package `tikv-jemallocator v0.5.4` ... which satisfies dependency `tikv-jemallocator = "^0.5.0"` of package `neard v0.0.0 (…)` --- Cargo.lock | 33 ++++++------------------ Cargo.toml | 2 +- core/store/src/db/rocksdb.rs | 50 +++++++++++++++--------------------- 3 files changed, 30 insertions(+), 55 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c2a49977688..e2a6ba845de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -850,17 +850,16 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.65.1" +version = "0.69.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" +checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", "cexpr", "clang-sys", + "itertools 0.12.1", "lazy_static", "lazycell", - "peeking_take_while", - "prettyplease", "proc-macro2", "quote", "regex", @@ -3637,9 +3636,9 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "librocksdb-sys" -version = "0.11.0+8.1.1" +version = "0.16.0+8.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3386f101bcb4bd252d8e9d2fb41ec3b0862a15a62b478c355b2982efa469e3e" +checksum = "ce3d60bc059831dc1c83903fb45c103f75db65c5a7bf22272764d9cc683e348c" dependencies = [ "bindgen", "bzip2-sys", @@ -6167,12 +6166,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - [[package]] name = "pem" version = "0.8.3" @@ -6324,16 +6317,6 @@ dependencies = [ "yansi", ] -[[package]] -name = "prettyplease" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ceca8aaf45b5c46ec7ed39fff75f57290368c1846d33d24a122ca81416ab058" -dependencies = [ - "proc-macro2", - "syn 2.0.87", -] - [[package]] name = "primitive-types" version = "0.10.1" @@ -7042,9 +7025,9 @@ dependencies = [ [[package]] name = "rocksdb" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6f170a4041d50a0ce04b0d2e14916d6ca863ea2e422689a5b694395d299ffe" +checksum = "6bd13e55d6d7b8cd0ea569161127567cd587676c99f4472f779a0279aa60a7a7" dependencies = [ "libc", "librocksdb-sys", diff --git a/Cargo.toml b/Cargo.toml index 05e063e0363..cbe657288f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -329,7 +329,7 @@ ripemd = "0.1.1" rkyv = "0.8.0" rlimit = "0.7" rlp = "0.5.2" -rocksdb = { version = "0.21.0", default-features = false, features = [ +rocksdb = { version = "0.22.0", default-features = false, features = [ "snappy", "lz4", "zstd", diff --git a/core/store/src/db/rocksdb.rs b/core/store/src/db/rocksdb.rs index 1cca0e3166b..384f480a7e5 100644 --- a/core/store/src/db/rocksdb.rs +++ b/core/store/src/db/rocksdb.rs @@ -2,12 +2,12 @@ use crate::config::Mode; use crate::db::{refcount, DBIterator, DBOp, DBSlice, DBTransaction, Database, StatsValue}; use crate::{metadata, metrics, DBCol, StoreConfig, StoreStatistics, Temperature}; use ::rocksdb::{ - BlockBasedOptions, Cache, ColumnFamily, Env, IteratorMode, Options, ReadOptions, WriteBatch, DB, + properties, BlockBasedOptions, Cache, ColumnFamily, Env, IteratorMode, Options, ReadOptions, + WriteBatch, DB, }; use anyhow::Context; use itertools::Itertools; use std::io; -use std::ops::Deref; use std::path::Path; use std::sync::LazyLock; use strum::IntoEnumIterator; @@ -19,28 +19,23 @@ pub(crate) mod snapshot; /// List of integer RocskDB properties we’re reading when collecting statistics. /// /// In the end, they are exported as Prometheus metrics. -static CF_PROPERTY_NAMES: LazyLock> = LazyLock::new(|| { - use ::rocksdb::properties; - let mut ret = Vec::new(); - ret.extend_from_slice( - &[ - properties::LIVE_SST_FILES_SIZE, - properties::ESTIMATE_LIVE_DATA_SIZE, - properties::COMPACTION_PENDING, - properties::NUM_RUNNING_COMPACTIONS, - properties::ESTIMATE_PENDING_COMPACTION_BYTES, - properties::ESTIMATE_TABLE_READERS_MEM, - properties::BLOCK_CACHE_CAPACITY, - properties::BLOCK_CACHE_USAGE, - properties::CUR_SIZE_ACTIVE_MEM_TABLE, - properties::SIZE_ALL_MEM_TABLES, - ] - .map(std::ffi::CStr::to_owned), - ); - for level in 0..=6 { - ret.push(properties::num_files_at_level(level)); - } - ret +static CF_PROPERTY_NAMES: LazyLock> = LazyLock::new(|| { + [ + properties::LIVE_SST_FILES_SIZE, + properties::ESTIMATE_LIVE_DATA_SIZE, + properties::COMPACTION_PENDING, + properties::NUM_RUNNING_COMPACTIONS, + properties::ESTIMATE_PENDING_COMPACTION_BYTES, + properties::ESTIMATE_TABLE_READERS_MEM, + properties::BLOCK_CACHE_CAPACITY, + properties::BLOCK_CACHE_USAGE, + properties::CUR_SIZE_ACTIVE_MEM_TABLE, + properties::SIZE_ALL_MEM_TABLES, + ] + .into_iter() + .map(properties::PropName::to_owned) + .chain((0..7).map(properties::num_files_at_level)) + .collect() }); pub struct RocksDB { @@ -668,7 +663,7 @@ impl RocksDB { /// Gets every int property in CF_PROPERTY_NAMES for every column in DBCol. fn get_cf_statistics(&self, result: &mut StoreStatistics) { - for prop_name in CF_PROPERTY_NAMES.deref() { + for prop_name in CF_PROPERTY_NAMES.iter() { let values = self .cf_handles() .filter_map(|(col, handle)| { @@ -677,10 +672,7 @@ impl RocksDB { }) .collect::>(); if !values.is_empty() { - // TODO(mina86): Once const_str_from_utf8 is stabilised we might - // be able convert this runtime UTF-8 validation into const. - let stat_name = prop_name.to_str().unwrap(); - result.data.push((stat_name.to_string(), values)); + result.data.push((prop_name.as_str().into(), values)); } } }