Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove parity-util-mem #696

Merged
merged 2 commits into from Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion kvdb-memorydb/Cargo.toml
Expand Up @@ -9,7 +9,6 @@ edition = "2021"
rust-version = "1.56.1"

[dependencies]
parity-util-mem = { path = "../parity-util-mem", version = "0.12", default-features = false, features = ["std"] }
parking_lot = "0.12.0"
kvdb = { version = "0.12", path = "../kvdb" }

Expand Down
3 changes: 1 addition & 2 deletions kvdb-memorydb/src/lib.rs
Expand Up @@ -7,7 +7,6 @@
// except according to those terms.

use kvdb::{DBKeyValue, DBOp, DBTransaction, DBValue, KeyValueDB};
use parity_util_mem::MallocSizeOf;
use parking_lot::RwLock;
use std::{
collections::{BTreeMap, HashMap},
Expand All @@ -16,7 +15,7 @@ use std::{

/// A key-value database fulfilling the `KeyValueDB` trait, living in memory.
/// This is generally intended for tests and is not particularly optimized.
#[derive(Default, MallocSizeOf)]
#[derive(Default)]
pub struct InMemory {
columns: RwLock<HashMap<u32, BTreeMap<Vec<u8>, DBValue>>>,
}
Expand Down
1 change: 0 additions & 1 deletion kvdb-rocksdb/Cargo.toml
Expand Up @@ -19,7 +19,6 @@ log = "0.4.8"
num_cpus = "1.10.1"
parking_lot = "0.12.0"
regex = "1.3.1"
parity-util-mem = { path = "../parity-util-mem", version = "0.12", default-features = false, features = ["std", "smallvec"] }

# OpenBSD and MSVC are unteested and shouldn't enable jemalloc:
# https://github.com/tikv/jemallocator/blob/52de4257fab3e770f73d5174c12a095b49572fba/jemalloc-sys/build.rs#L26-L27
Expand Down
1 change: 0 additions & 1 deletion kvdb-rocksdb/examples/memtest.rs
Expand Up @@ -145,7 +145,6 @@ fn main() {
println!("{}", timestamp);
println!("\tData written: {} keys - {} Mb", step + 1, ((step + 1) * 64 * 128) / 1024 / 1024);
println!("\tProcess memory used as seen by the OS: {} Mb", proc_memory_usage() / 1024);
println!("\tMemory used as reported by rocksdb: {} Mb\n", parity_util_mem::malloc_size(&db) / 1024 / 1024);
}

step += 1;
Expand Down
29 changes: 0 additions & 29 deletions kvdb-rocksdb/src/lib.rs
Expand Up @@ -16,7 +16,6 @@ use std::{
path::{Path, PathBuf},
};

use parity_util_mem::MallocSizeOf;
use rocksdb::{
BlockBasedOptions, ColumnFamily, ColumnFamilyDescriptor, Options, ReadOptions, WriteBatch, WriteOptions, DB,
};
Expand Down Expand Up @@ -252,26 +251,6 @@ struct DBAndColumns {
column_names: Vec<String>,
}

impl MallocSizeOf for DBAndColumns {
fn size_of(&self, ops: &mut parity_util_mem::MallocSizeOfOps) -> usize {
let mut total = self.column_names.size_of(ops)
// we have at least one column always, so we can call property on it
+ self.cf(0).map(|cf| self.db
.property_int_value_cf(cf, "rocksdb.block-cache-usage")
.unwrap_or(Some(0))
.map(|x| x as usize)
.unwrap_or(0)
).unwrap_or(0);

for v in 0..self.column_names.len() {
total += self.static_property_or_warn(v, "rocksdb.estimate-table-readers-mem");
total += self.static_property_or_warn(v, "rocksdb.cur-size-all-mem-tables");
}

total
}
}

impl DBAndColumns {
fn cf(&self, i: usize) -> io::Result<&ColumnFamily> {
let name = self.column_names.get(i).ok_or_else(|| invalid_column(i as u32))?;
Expand Down Expand Up @@ -299,22 +278,14 @@ impl DBAndColumns {
}

/// Key-Value database.
#[derive(MallocSizeOf)]
pub struct Database {
inner: DBAndColumns,
#[ignore_malloc_size_of = "insignificant"]
config: DatabaseConfig,
#[ignore_malloc_size_of = "insignificant"]
path: PathBuf,
#[ignore_malloc_size_of = "insignificant"]
opts: Options,
#[ignore_malloc_size_of = "insignificant"]
write_opts: WriteOptions,
#[ignore_malloc_size_of = "insignificant"]
read_opts: ReadOptions,
#[ignore_malloc_size_of = "insignificant"]
block_opts: BlockBasedOptions,
#[ignore_malloc_size_of = "insignificant"]
stats: stats::RunningDbStats,
}

Expand Down
1 change: 0 additions & 1 deletion kvdb/Cargo.toml
Expand Up @@ -10,4 +10,3 @@ rust-version = "1.56.1"

[dependencies]
smallvec = "1.0.0"
parity-util-mem = { path = "../parity-util-mem", version = "0.12", default-features = false }
2 changes: 1 addition & 1 deletion kvdb/src/lib.rs
Expand Up @@ -104,7 +104,7 @@ impl DBTransaction {
///
/// The API laid out here, along with the `Sync` bound implies interior synchronization for
/// implementation.
pub trait KeyValueDB: Sync + Send + parity_util_mem::MallocSizeOf {
pub trait KeyValueDB: Sync + Send {
/// Helper to create a new transaction.
fn transaction(&self) -> DBTransaction {
DBTransaction::new()
Expand Down