Skip to content

Remove heapsize #94

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

Merged
merged 49 commits into from
May 31, 2019
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
25270be
Mem tools by including trait and specific implementation in the crate
cheme Dec 6, 2018
94bb293
Plug malloc_size_of as a patched copy. Documentation is done by
cheme Dec 7, 2018
197a27d
A few additional impl for parity-eth use
cheme Dec 7, 2018
f816aaf
Removal of heapsize (no proper crate versioning and pending on mem crate
cheme Dec 7, 2018
2a0cc08
Allocators.
cheme Dec 7, 2018
418e03b
heapsize estimation for allocator without use_size fn.
cheme Dec 10, 2018
6105606
Init no_std compat.
cheme Dec 10, 2018
59b4d55
Remove conditianal test code.
cheme Dec 10, 2018
efadc31
Renaming of mem repo to crate name.
cheme Dec 11, 2018
b2f1708
Remove conditional mettering for now (will need some testing to check if
cheme Dec 11, 2018
fb127a7
tab
cheme Dec 11, 2018
d5aa899
Remove features get form malloc_size and simply delete code instead.
cheme Jan 2, 2019
fd9dc92
Update parity-util-mem/README.md
pepyakin Jan 2, 2019
3df427b
Missing windows import
cheme Jan 3, 2019
da88f97
Merge branch 'mem-tools2' of github.com:cheme/parity-common into mem-…
cheme Jan 3, 2019
ef9a5b6
Use self for winapi.
cheme Jan 3, 2019
1b0b2e3
Correct import.
cheme Jan 3, 2019
8839576
Merge branch 'master' into rem_heapsize
cheme Jan 3, 2019
5fd398f
Small renaming, test confirm that only memorydb need update before
cheme Jan 3, 2019
5340912
shallow size on Arc with malloc return -1 (max val), replacing with
cheme Jan 3, 2019
8ada814
use cfg_if to makes feature choice more explicit.
cheme Jan 7, 2019
e3516d2
Plug on github branch (test brokens)
cheme Jan 9, 2019
61c60b0
Remove servo specific impls (unused).
cheme Jan 9, 2019
767dc90
`estimate_heapsize` in travis.
cheme Jan 9, 2019
9876b65
Merge branch 'master' into mem-tools2
cheme Jan 9, 2019
a8a9b0e
Merge branch 'master' into mem-tools2
cheme Jan 9, 2019
a31851e
Remove last serde and remove servo_arc reference.
cheme Jan 10, 2019
73e8c7e
Add missing version
cheme Jan 10, 2019
64135ac
Use malloc_size_of_derive from crates.
cheme Jan 12, 2019
af24ca4
Merge branch 'mem-tools2' into rem_heapsize
cheme Jan 14, 2019
00a0931
Merge branch 'mem-tools2' into rem_heapsize
cheme Jan 14, 2019
d85752e
Update versioning for breaking change
cheme Jan 14, 2019
32beba3
Merge branch 'rem_heapsize' of github.com:cheme/parity-common into re…
cheme Jan 14, 2019
ac83cdd
Clean heapsize uses.
cheme Jan 14, 2019
bce898c
Updating uint version, 0.6.0 has been published already.
cheme Jan 16, 2019
821c02c
Missing reference to uint 0.7.0
cheme Jan 16, 2019
85597c0
Merge branch 'master' into rem_heapsize
cheme Jan 16, 2019
d770316
Merge branch 'master' into rem_heapsize, and update uint readme crate
cheme Jan 16, 2019
a0a2577
Merge branch 'master' into rem_heapsize
cheme Jan 16, 2019
ca27409
restore test dependency
cheme Jan 16, 2019
c6a6982
Merge branch 'master' into rem_heapsize, remove clear_on_drop from
cheme May 31, 2019
b7de962
Update keccak-hash/Cargo.toml
cheme May 31, 2019
a65dcdb
fix readme comment
cheme May 31, 2019
45860cd
Allow no_std for estimate_size
cheme May 31, 2019
ba4dd7c
Merge branch 'rem_heapsize' of github.com:cheme/parity-common into re…
cheme May 31, 2019
96c860b
use a version, not sure a major version only is valid for publishing
cheme May 31, 2019
1b0bc65
fix warnings
cheme May 31, 2019
0fbc1ce
fix warnings
cheme May 31, 2019
18d3f99
fix string import warning
cheme May 31, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions fixed-hash/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fixed-hash"
version = "0.3.0"
version = "0.4.0"
authors = ["Parity Technologies <[email protected]>"]
license = "MIT"
homepage = "https://github.com/paritytech/parity-common"
Expand All @@ -10,10 +10,9 @@ documentation = "https://docs.rs/fixed-hash/"
readme = "README.md"

[package.metadata.docs.rs]
features = ["heapsize", "quickcheck", "api-dummy"]
features = ["quickcheck", "api-dummy"]

[dependencies]
heapsize = { version = "0.4", optional = true }
rand = { version = "0.5", optional = true, default-features = false }
rustc-hex = { version = "2.0", optional = true, default-features = false }
quickcheck = { version = "0.7", optional = true }
Expand Down
2 changes: 0 additions & 2 deletions fixed-hash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ fixed-hash = { version = "0.3", default-features = false }
- Enabled by default.
- `byteorder`: Provide API based on the `byteorder` crate.
- Enabled by default.
- `heapsize`: Provide `HeapsizeOf` implementation for hash types.
- Disabled by default.
- `quickcheck`: Provide `quickcheck` implementation for hash types.
- Disabled by default.
- `api-dummy`: Generate a dummy hash type for API documentation.
Expand Down
40 changes: 0 additions & 40 deletions fixed-hash/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ macro_rules! construct_fixed_hash {
impl_rand_for_fixed_hash!($name);
impl_libc_for_fixed_hash!($name);
impl_rustc_hex_for_fixed_hash!($name);
impl_heapsize_for_fixed_hash!($name);
impl_quickcheck_for_fixed_hash!($name);
}
}
Expand Down Expand Up @@ -665,45 +664,6 @@ macro_rules! impl_rustc_hex_for_fixed_hash {
}
}

// Implementation for disabled heapsize crate support.
//
// # Note
//
// Feature guarded macro definitions instead of feature guarded impl blocks
// to work around the problems of introducing `heapsize` crate feature in
// a user crate.
#[cfg(not(
all(feature = "heapsize", not(target_os = "unknown"))
))]
#[macro_export]
#[doc(hidden)]
macro_rules! impl_heapsize_for_fixed_hash {
( $name:ident ) => {}
}

// Implementation for enabled heapsize crate support.
//
// # Note
//
// Feature guarded macro definitions instead of feature guarded impl blocks
// to work around the problems of introducing `heapsize` crate feature in
// a user crate.
#[cfg(
all(feature = "heapsize", not(target_os = "unknown"))
)]
#[macro_export]
#[doc(hidden)]
macro_rules! impl_heapsize_for_fixed_hash {
( $name:ident ) => {
impl $crate::heapsize::HeapSizeOf for $name {
#[inline]
fn heap_size_of_children(&self) -> usize {
0
}
}
}
}

// Implementation for disabled quickcheck crate support.
//
// # Note
Expand Down
4 changes: 0 additions & 4 deletions fixed-hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ pub extern crate byteorder;
#[doc(hidden)]
pub mod libc {}

#[cfg(feature = "heapsize")]
#[doc(hidden)]
pub extern crate heapsize;

#[cfg(feature = "rustc-hex")]
#[doc(hidden)]
pub extern crate rustc_hex;
Expand Down
11 changes: 0 additions & 11 deletions fixed-hash/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,17 +310,6 @@ mod from_str {
}
}

#[cfg(all(
feature = "heapsize",
not(target_os = "unknown")
))]
#[test]
fn test_heapsizeof() {
use heapsize::HeapSizeOf;
let h = H128::zero();
assert_eq!(h.heap_size_of_children(), 0);
}

#[test]
fn from_h160_to_h256() {
let h160 = H160::from([
Expand Down
8 changes: 4 additions & 4 deletions memorydb/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[package]
name = "memorydb"
version = "0.3.0"
version = "0.4.0"
authors = ["Parity Technologies <[email protected]>"]
description = "in-memory implementation of hashdb"
repository = "https://github.com/paritytech/parity-common"
license = "GPL-3.0"

[dependencies]
heapsize = "0.4"
parity-util-mem = { version = "0.1", path = "../parity-util-mem" }
hashdb = { version = "0.3.0", path = "../hashdb" }
plain_hasher = { version = "0.2", path = "../plain_hasher", default-features = false }
rlp = { version = "0.3.0", path = "../rlp", default-features = false }

[dev-dependencies]
tiny-keccak = "1.4.2"
ethereum-types = "0.4"
keccak-hasher = { version = "0.1", path = "../test-support/keccak-hasher" }
keccak-hash = { version = "0.1", path = "../keccak-hash" }
keccak-hasher = { version = "*" } # , path = "../test-support/keccak-hasher" }
keccak-hash = { version = "*" } #, path = "../keccak-hash" }
28 changes: 19 additions & 9 deletions memorydb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

//! Reference-counted memory-based `HashDB` implementation.
extern crate hashdb;
extern crate heapsize;
extern crate parity_util_mem as malloc_size_of;
extern crate rlp;
#[cfg(test)] extern crate keccak_hasher;
#[cfg(test)] extern crate tiny_keccak;
#[cfg(test)] extern crate ethereum_types;

use hashdb::{HashDB, Hasher as KeyHasher, AsHashDB};
use heapsize::HeapSizeOf;
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps, MallocSizeOfExt};
use rlp::NULL_RLP;
use std::collections::hash_map::Entry;
use std::collections::HashMap;
Expand Down Expand Up @@ -91,7 +91,6 @@ pub struct MemoryDB<H: KeyHasher, T> {
impl<'a, H, T> Default for MemoryDB<H, T>
where
H: KeyHasher,
H::Out: HeapSizeOf,
T: From<&'a [u8]> + Clone
{
fn default() -> Self { Self::new() }
Expand All @@ -100,7 +99,6 @@ where
impl<'a, H, T> MemoryDB<H, T>
where
H: KeyHasher,
H::Out: HeapSizeOf,
T: From<&'a [u8]> + Clone,
{
/// Create a new instance of the memory DB.
Expand All @@ -112,7 +110,6 @@ where
impl<H, T> MemoryDB<H, T>
where
H: KeyHasher,
H::Out: HeapSizeOf,
T: Default,
{
/// Remove an element and delete it from storage if reference count reaches zero.
Expand Down Expand Up @@ -216,13 +213,26 @@ impl<H: KeyHasher, T: Clone> MemoryDB<H, T> {

impl<H, T> MemoryDB<H, T>
where
H: KeyHasher,
H::Out: HeapSizeOf,
T: HeapSizeOf,
H: KeyHasher,
H::Out: MallocSizeOf,
T: MallocSizeOf,
{
/// Returns the size of allocated heap memory
pub fn mem_used(&self) -> usize {
self.data.heap_size_of_children()
self.malloc_size_of()
}
}

impl<H, T> MallocSizeOf for MemoryDB<H, T>
where
H: KeyHasher,
H::Out: MallocSizeOf,
T: MallocSizeOf,
{
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
self.data.size_of(ops)
+ self.null_node_data.size_of(ops)
+ self.hashed_null_node.size_of(ops)
}
}

Expand Down
2 changes: 1 addition & 1 deletion patricia_trie/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ parity-bytes = { version = "0.1", path = "../parity-bytes" }
env_logger = "0.5"
ethereum-types = "0.4"
keccak-hash = { version = "0.1", path = "../keccak-hash" }
memorydb = { version = "0.3.0", path = "../memorydb", default-features = false }
memorydb = { version = "0.4.0", path = "../memorydb", default-features = false }
rlp = { version = "0.3.0", path = "../rlp", default-features = false }
trie-standardmap = { version = "0.1", path = "../trie-standardmap", default-features = false }
triehash = { version = "0.3.0", path = "../triehash", default-features = false }
Expand Down
7 changes: 3 additions & 4 deletions primitive-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
[package]
name = "primitive-types"
version = "0.1.5"
version = "0.2.0"
authors = ["Parity Technologies <[email protected]>"]
license = "Apache-2.0/MIT"
homepage = "https://github.com/paritytech/parity-common"
description = "Primitive types shared by Ethereum and Substrate"

[dependencies]
fixed-hash = { version = "0.3", path = "../fixed-hash", default-features = false }
uint = { version = "0.6", path = "../uint", default-features = false }
fixed-hash = { version = "0.4", path = "../fixed-hash", default-features = false }
uint = { version = "0.7", path = "../uint", default-features = false }
impl-serde = { version = "0.1", path = "impls/serde", default-features = false, optional = true }
impl-codec = { version = "0.1", path = "impls/codec", default-features = false, optional = true }
impl-rlp = { version = "0.1", path = "impls/rlp", default-features = false, optional = true }

[features]
default = ["std"]
std = ["uint/std", "fixed-hash/std", "impl-codec/std"]
heapsize = ["uint/heapsize", "fixed-hash/heapsize"]
byteorder = ["fixed-hash/byteorder"]
libc = ["fixed-hash/libc"]
rustc-hex = ["fixed-hash/rustc-hex"]
Expand Down
3 changes: 1 addition & 2 deletions uint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ homepage = "http://parity.io"
repository = "https://github.com/paritytech/parity-common"
license = "MIT/Apache-2.0"
name = "uint"
version = "0.6.0"
version = "0.7.0"
authors = ["Parity Technologies <[email protected]>"]
readme = "README.md"

[dependencies]
byteorder = { version = "1", default-features = false }
heapsize = { version = "0.4.2", optional = true }
rustc-hex = { version = "2.0", default-features = false }
quickcheck = { version = "0.6", optional = true }
crunchy = { version = "0.2", default-features = true }
Expand Down
2 changes: 0 additions & 2 deletions uint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,3 @@ cargo bench
- Enabled by default.
- `quickcheck`: Enable quickcheck-style property testing
- Use with `cargo test --release --features=quickcheck`.
- `heapsize`: Implement base trait of the `heapsizeof` crate
- Use with `cargo build --feature=heapsize`.
4 changes: 0 additions & 4 deletions uint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
#[doc(hidden)]
pub extern crate byteorder;

#[cfg(feature="heapsize")]
#[doc(hidden)]
pub extern crate heapsize;

// Re-export libcore using an alias so that the macros can work without
// requiring `extern crate core` downstream.
#[doc(hidden)]
Expand Down
21 changes: 0 additions & 21 deletions uint/src/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,6 @@ macro_rules! construct_uint {
}

impl_std_for_uint!($name, $n_words);
impl_heapsize_for_uint!($name);
// `$n_words * 8` because macro expects bytes and
// uints use 64 bit (8 byte) words
impl_quickcheck_arbitrary_for_uint!($name, ($n_words * 8));
Expand Down Expand Up @@ -1359,26 +1358,6 @@ macro_rules! impl_std_for_uint {
($name: ident, $n_words: tt) => {}
}

#[cfg(feature="heapsize")]
#[macro_export]
#[doc(hidden)]
macro_rules! impl_heapsize_for_uint {
($name: ident) => {
impl $crate::heapsize::HeapSizeOf for $name {
fn heap_size_of_children(&self) -> usize {
0
}
}
}
}

#[cfg(not(feature="heapsize"))]
#[macro_export]
#[doc(hidden)]
macro_rules! impl_heapsize_for_uint {
($name: ident) => {}
}

#[cfg(feature="quickcheck")]
#[macro_export]
#[doc(hidden)]
Expand Down