feat(bench): add AggOp memory profiler#144
Conversation
2 concrete findings from memprofile1. Boxing large
|
|
|
||
| impl MemUsage for AggOp { | ||
| fn mem_profile(&self) -> MemProfile { | ||
| let enum_slot_bytes = size_of::<AggOp>(); |
There was a problem hiding this comment.
i think this should be core::mem::size_of_val(core::mem::discriminant(self))
|
|
||
| impl MemProfile { | ||
| pub fn new(label: impl Into<String>, stack_bytes: usize) -> Self { | ||
| Self { |
There was a problem hiding this comment.
should enum_slot_bytes = 0 and payload_bytes = 0?
| } | ||
|
|
||
| pub fn with_stack_composition(mut self, enum_slot_bytes: usize, payload_bytes: usize) -> Self { | ||
| self.stack_bytes = enum_slot_bytes; |
There was a problem hiding this comment.
setting stack_bytes = enum_slot_bytes seems wrong
| self.stack_bytes = enum_slot_bytes; | ||
| self.enum_slot_bytes = enum_slot_bytes; | ||
| self.payload_bytes = payload_bytes; | ||
| self.slack_bytes = enum_slot_bytes.saturating_sub(payload_bytes); |
There was a problem hiding this comment.
i think this should be self.stack_bytes.saturating_sub(enum_slot_bytes).saturating_sub(payload_bytes)
| impl MemUsage for AggOp { | ||
| fn mem_profile(&self) -> MemProfile { | ||
| let enum_slot_bytes = size_of::<AggOp>(); | ||
| let mut profile = MemProfile::new(aggop_label(self), enum_slot_bytes) |
There was a problem hiding this comment.
i think this should be MemProfile::new(aggop_label(self), size_of::<AggOp>())
| profile | ||
| } | ||
|
|
||
| fn value_vec_breakdown(profile: &mut MemProfile, label: &str, values: &Vec<Value>) { |
There was a problem hiding this comment.
value_vec_breakdown relies on capacity() * size_of::<T>(). this can be wrong when it's applied to Vec<Value> since Value is an enum containing other heap-allocated objects
| ); | ||
| } | ||
|
|
||
| fn value_deque_breakdown(profile: &mut MemProfile, label: &str, values: &VecDeque<Value>) { |
There was a problem hiding this comment.
same issue with value_vec_breakdown
Summary
Adds a
memprofilebench binary for profiling per-AggOpstructural memory usage against the workloads. This is the first part of #68, which enables further analysis.Linked issues
Related to #68
What changed
This PR adds a memprofile bench binary that profiles structural memory usage for each AggOp in the fraud workload. It introduces reusable MemUsage / MemProfile accounting in beava-core, generates a ranked Markdown report of per-op stack and heap estimates, and highlights the largest memory contributors.
Verification
Paste the summary block from
bash .github/scripts/check.shhere so thereviewer can see the local run passed:
Pre-flight checklist
bash .github/scripts/check.shexits 0 (or each step passes manually)docs/*.md,beava-website/project/docs/, decorator docstrings) if user-visible behavior changedbeava-dev/beava)beava-website/deploy/site-metrics-pipeline.json, called out in this PR body — the deploy workflow re-registers withforce=true, which silently lands destructive edits