Skip to content

Commit

Permalink
Remove parity-util-mem (#696)
Browse files Browse the repository at this point in the history
* Remove `parity-util-mem`

* Remove reference to `parity-util-mem` from CI
  • Loading branch information
mrcnski authored Nov 29, 2022
1 parent fc75eaa commit 806ca48
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 56 deletions.
20 changes: 0 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,6 @@ jobs:
command: test
args: -p uint --target=mips64-unknown-linux-gnuabi64

- name: Test parity-util-mem on Android
if: runner.os == 'Linux'
uses: actions-rs/cargo@v1
with:
use-cross: true
command: test
args: -p parity-util-mem --target=aarch64-linux-android

- name: Test parity-util-mem estimate-heapsize
run: cargo test -p parity-util-mem --features='estimate-heapsize'

- name: Test parity-util-mem jemalloc-global
run: cargo test -p parity-util-mem --features='jemalloc-global'

- name: Test parity-util-mem mimalloc-global
run: cargo test -p parity-util-mem --features='mimalloc-global'

- name: Test parity-util-mem dlmalloc-global
run: cargo test -p parity-util-mem --no-default-features --features='dlmalloc-global'

test_windows:
name: Test Windows
runs-on: windows-latest
Expand Down
1 change: 0 additions & 1 deletion kvdb-memorydb/Cargo.toml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 806ca48

Please sign in to comment.