Skip to content

Commit d548cfb

Browse files
authored
Merge pull request #1002 from openmina/feat/malloc_size_of
Use malloc_sizeof
2 parents 2d5bc2c + 13e4b62 commit d548cfb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1446
-369
lines changed

Cargo.lock

Lines changed: 211 additions & 140 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,27 @@ poly-commitment = {git = "https://github.com/openmina/proof-systems", rev = "dec
5858
libp2p = { git = "https://github.com/openmina/rust-libp2p", rev = "5c44c7d9", default-features = false }
5959
vrf = { path = "vrf" }
6060
openmina-node-account = { path = "node/account" }
61-
redux = { git = "https://github.com/openmina/redux-rs.git", rev = "ab14890c", features = ["serde"] }
61+
redux = { git = "https://github.com/openmina/redux-rs.git", rev = "ab14890c", features = [
62+
"serde",
63+
] }
6264
serde = "1.0.190"
6365
serde_json = "1.0.107"
6466
serde_with = { version = "3.7.0", features = ["hex"] }
6567
linkme = "0.3.22"
6668
static_assertions = "1.1.0"
6769
juniper = { version = "0.16" }
6870

69-
ark-ff = { version = "0.3.0", features = [ "parallel", "asm", "std" ] }
71+
ark-ff = { version = "0.3.0", features = ["parallel", "asm", "std"] }
7072
# UNCOMMENTED_IN_CI ark-ff = { version = "0.3.0", features = [ "parallel", "asm", "std", "32x9" ] }
7173

74+
graphannis-malloc_size_of = { git = "https://github.com/openmina/graphannis-malloc_size_of.git", rev = "f7da9f6" }
75+
graphannis-malloc_size_of_derive = { git = "https://github.com/openmina/graphannis-malloc_size_of_derive.git" }
7276

7377
[profile.fuzz]
7478
inherits = "release"
7579
opt-level = 3
7680
debug = 2
77-
debug-assertions = true # TODO: test and disable if too slow
81+
debug-assertions = true # TODO: test and disable if too slow
7882
overflow-checks = true
7983
lto = false
8084
panic = "abort"
@@ -87,7 +91,7 @@ ark-ec = { git = "https://github.com/openmina/algebra", rev = "aea157a" } # bran
8791
ark-poly = { git = "https://github.com/openmina/algebra", rev = "aea157a" } # branch: fix-openmina-webnode
8892
ark-serialize = { git = "https://github.com/openmina/algebra", rev = "aea157a" } # branch: fix-openmina-webnode
8993

90-
num-bigint = { git = "https://github.com/openmina/num-bigint", rev = "8bb5ee4" } # branch: on-stack
94+
num-bigint = { git = "https://github.com/openmina/num-bigint", rev = "8bb5ee4" } # branch: on-stack
9195
num-rational = { git = "https://github.com/openmina/num-rational", rev = "336f11d" } # branch: on-stack
9296

9397
[profile.test.package."*"]

core/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,22 @@ base64 = "0.22"
2828
bs58 = "0.4.0"
2929
thiserror = "1.0.37"
3030

31+
graphannis-malloc_size_of = { workspace = true }
32+
graphannis-malloc_size_of_derive = { workspace = true }
33+
3134
mina-hasher = { workspace = true }
3235
mina-p2p-messages = { workspace = true }
3336
poseidon = { workspace = true }
3437
hex = "0.4.3"
3538
ark-ff = { workspace = true }
3639

3740
[target.'cfg(not(target_family = "wasm"))'.dependencies]
38-
redux = { workspace = true, features=["serializable_callbacks"] }
41+
redux = { workspace = true, features = ["serializable_callbacks"] }
3942

4043
[target.'cfg(target_family = "wasm")'.dependencies]
4144
wasm-bindgen = "0.2.99"
4245
wasm-bindgen-futures = "0.4.49"
43-
wasm_thread = { version = "0.3", features = [ "es_modules" ] }
46+
wasm_thread = { version = "0.3", features = ["es_modules"] }
4447
js-sys = "0.3"
4548
web-sys = { version = "0.3", features = ["Window", "Response"] }
4649

core/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
extern crate graphannis_malloc_size_of as malloc_size_of;
2+
extern crate graphannis_malloc_size_of_derive as malloc_size_of_derive;
3+
14
pub mod distributed_pool;
25
pub mod invariants;
36
pub mod log;

core/src/requests/request_id.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,15 @@ impl<T> Clone for RequestId<T> {
142142
}
143143

144144
impl<T> Copy for RequestId<T> {}
145+
146+
mod measurement {
147+
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
148+
149+
use super::RequestId;
150+
151+
impl<T> MallocSizeOf for RequestId<T> {
152+
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
153+
0
154+
}
155+
}
156+
}

core/src/snark/snark.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::sync::Arc;
22

3+
use malloc_size_of::MallocSizeOf;
34
use mina_p2p_messages::binprot::macros::{BinProtRead, BinProtWrite};
45
use mina_p2p_messages::v2::{
56
CurrencyFeeStableV1, MinaBaseFeeWithProverStableV1,
@@ -97,3 +98,10 @@ impl From<&Snark> for NetworkPoolSnarkPoolDiffVersionedStableV2AddSolvedWork1 {
9798
}
9899
}
99100
}
101+
102+
impl MallocSizeOf for Snark {
103+
fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
104+
usize::from(!ops.have_seen_ptr(Arc::as_ptr(&self.proofs)))
105+
* (size_of::<TransactionSnarkWorkTStableV2Proofs>() + self.proofs.size_of(ops))
106+
}
107+
}

mina-p2p-messages/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ ark-ff = { workspace = true }
3737
rsexp = "0.2.3"
3838
rsexp-derive = "0.2.3"
3939

40+
graphannis-malloc_size_of = { workspace = true }
41+
graphannis-malloc_size_of_derive = { workspace = true }
42+
4043
[target.'cfg(fuzzing)'.dev-dependencies]
4144
fuzzcheck = "0.12.1"
4245

mina-p2p-messages/src/array.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::ops::Deref;
22

33
use binprot::{BinProtRead, BinProtWrite, Nat0};
4+
use malloc_size_of_derive::MallocSizeOf;
45
use rsexp::OfSexp;
56
use serde::{Deserialize, Serialize};
67

@@ -17,6 +18,7 @@ use serde::{Deserialize, Serialize};
1718
Deserialize,
1819
derive_more::From,
1920
derive_more::Into,
21+
MallocSizeOf,
2022
)]
2123
pub struct ArrayN<T, const N: u64>(Vec<T>);
2224

mina-p2p-messages/src/b58.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::str::FromStr;
77
use binprot::{BinProtRead, BinProtWrite};
88
use binprot_derive::{BinProtRead, BinProtWrite};
99
use derive_more::From;
10+
use malloc_size_of_derive::MallocSizeOf;
1011
use serde::{Deserialize, Serialize};
1112

1213
/// Before encoding, data is prepended with the version byte.
@@ -84,7 +85,7 @@ where
8485

8586
/// Wrapper that uses base58check of binprot serialization for the wrapped type
8687
/// for human readable serializer.
87-
#[derive(PartialEq, Eq, PartialOrd, Ord)]
88+
#[derive(PartialEq, Eq, PartialOrd, Ord, MallocSizeOf)]
8889
pub struct Base58CheckOfBinProt<T, U, const V: u8>(T, PhantomData<U>);
8990

9091
impl<T, U, const V: u8> Default for Base58CheckOfBinProt<T, U, V>

mina-p2p-messages/src/bigint.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use ark_ff::{fields::arithmetic::InvalidBigInt, BigInteger256};
2+
use malloc_size_of::MallocSizeOf;
23
use rsexp::{OfSexp, SexpOf};
34
use serde::{Deserialize, Serialize};
45

@@ -13,6 +14,12 @@ impl std::fmt::Debug for BigInt {
1314
}
1415
}
1516

17+
impl MallocSizeOf for BigInt {
18+
fn size_of(&self, _ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
19+
0
20+
}
21+
}
22+
1623
#[derive(Debug, thiserror::Error)]
1724
#[error("Invalid decimal number")]
1825
pub struct InvalidDecimalNumber;

0 commit comments

Comments
 (0)