Use heap allocations for longedges to reduce memory usage of prepared graphs
nmandery opened this issue · 0 comments
nmandery commented
https://github.com/nnethercote/perf-book
use std::collections::HashSet;
struct LongEdge {
in_edge: u64,
out_edge: u64,
edge_path: Vec<u64>,
cell_lookup: HashSet<u64>,
}
struct OwnedEdgeValueBoxed {
weight: f32,
longedge: Option<Box<(LongEdge, f32)>>,
}
struct OwnedEdgeValue {
weight: f32,
longedge: Option<(LongEdge, f32)>,
}
fn main() {
dbg!(std::mem::size_of::<OwnedEdgeValue>());
dbg!(std::mem::size_of::<OwnedEdgeValueBoxed>());
}
Output:
Finished dev [unoptimized + debuginfo] target(s) in 0.58s
Running `target/debug/playground`
[src/main.rs:22] std::mem::size_of::<OwnedEdgeValue>() = 104
[src/main.rs:23] std::mem::size_of::<OwnedEdgeValueBoxed>() = 16