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

Initialize a crate for memory related tools #89

Merged
merged 25 commits into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 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
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
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
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
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ script:
- cd uint/ && cargo test --features=std,quickcheck --release && cd ..
- cd hashdb/ && cargo test --no-default-features && cd ..
- cd plain_hasher/ && cargo test --no-default-features && cd ..
- cd parity-util-mem/ && cargo test --features=estimate-heapsize && cd ..
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ members = [
"trie-standardmap",
"triehash",
"uint",
"parity-util-mem",
"primitive-types",
]
38 changes: 38 additions & 0 deletions parity-util-mem/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "parity-util-mem"
version = "0.1.0"
authors = ["Parity Technologies <[email protected]>"]
repository = "https://github.com/paritytech/parity-common"
description = "Collection of memory related utilities"
license = "GPL-3.0"

[dependencies]
clear_on_drop = "0.2"
cfg-if = "0.1.6"
malloc_size_of_derive = "0.1.0"
dlmalloc = { version = "0.1", features = ["global"], optional = true }
wee_alloc = { version = "0.4", optional = true }
jemallocator = { version = "0.1", optional = true }

elastic-array = { version = "*", optional = true }
ethereum-types = { version = "*", optional = true }
parking_lot = { version = "*", optional = true }

[target."cfg(windows)".dependencies.winapi]
version = "0.3.4"

[features]
default = ["std", "ethereum-impls"]
std = []
# when activated mem is removed through volatile primitive instead of clear_on_drop crate
volatile-erase = []
# use dlmalloc as global allocator
dlmalloc-global = ["dlmalloc", "estimate-heapsize"]
# use wee_alloc as global allocator
weealloc-global = ["wee_alloc", "estimate-heapsize"]
# use jemalloc as global allocator
jemalloc-global = ["jemallocator"]
# implement additional types
ethereum-impls = ["ethereum-types", "elastic-array", "parking_lot"]
# Full estimate: no call to allocator
estimate-heapsize = []
16 changes: 16 additions & 0 deletions parity-util-mem/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# parity-util-mem

Collection of memory related utilities.

## Features

- volatile-erase : Not set by default, `Memzero` struct will be erasing memory through a simple [`write_volatile`](https://doc.rust-lang.org/std/ptr/fn.write_volatile.html) call.
- estimate-heapsize : Do not use allocator, but `size_of` or `size_of_val`.

Others features define global allocator, see `src/alloc.rs`.

## Dependency

This crate groups common dependency, [`clear_on_drop`](https://crates.io/crates/clear_on_drop) is reexported, and a patched copy of unpublished [`malloc_size_of`](https://github.com/servo/servo/tree/master/components/malloc_size_of) from servo project is copied and partially reexported.

`Malloc_size_of` code is used internally as a module with a few modification to be able to implement type locally.
12 changes: 12 additions & 0 deletions parity-util-mem/get_malloc_size_src.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# script/process to update code from servo project (malloc_size_of)
# untested, note that we do not use submodule due to size of git repo
git clone https://github.com/servo/servo.git
cd servo
git checkout 5bdea7dc1c80790a852a3fb03edfb2b8fbd403dc
git apply ../slim_malloc_size_of.patch
#git merge master
#cp components/malloc_size_of/lib.rs ../src/malloc_size.rs
#cd ..
#rm -rf ./servo
Loading