Skip to content

Commit 0ff1b1b

Browse files
committed
Fix heap profiling review issues
1 parent ee5735b commit 0ff1b1b

3 files changed

Lines changed: 6 additions & 15 deletions

File tree

crypto/stark/src/instruments.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@ pub fn heap_bytes() -> Option<usize> {
1313
HEAP_READER.get().map(|f| f())
1414
}
1515

16-
fn heap_mb() -> Option<usize> {
17-
heap_bytes().map(|b| b / (1024 * 1024))
18-
}
19-
2016
pub type HeapSnapshot = (&'static str, usize);
2117

2218
pub fn snap(label: &'static str) -> Option<HeapSnapshot> {
23-
heap_mb().map(|mb| (label, mb))
19+
heap_bytes().map(|b| (label, b))
2420
}
2521

2622
pub struct ProveHeapProfile {

prover/src/instruments.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,11 @@ pub fn print_report(
232232
print_row("After trace build", heap_profile.after_trace_build);
233233
print_row("After AIR construction", heap_profile.after_air);
234234
if let Some(ref mp_data) = mp {
235-
for (label, snap_mb) in &mp_data.heap_snapshots {
236-
let snap_bytes = snap_mb * (1024 * 1024);
237-
let cur = *snap_mb;
235+
for (label, bytes) in &mp_data.heap_snapshots {
236+
let cur = mb(*bytes);
238237
let delta = cur as isize - mb(prev) as isize;
239238
eprintln!(" {:<36} {:>7} {:>+8}", label, cur, delta);
240-
prev = snap_bytes;
239+
prev = *bytes;
241240
}
242241
}
243242
eprintln!(" {}", "─".repeat(56));

scripts/bench_heap_profile.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fi
4949
CLI="$ROOT_DIR/target/release/cli"
5050

5151
# Phase labels we parse from stderr (order matters)
52-
PHASES="execute trace_build air pool_alloc main_commits aux_build aux_commit rounds_2_4"
52+
PHASES="execute trace_build air pool_alloc main_commits aux_build aux_commit"
5353

5454
for size in $PROGRAMS; do
5555
ELF="$ELF_DIR/fib_iterative_${size}.elf"
@@ -63,15 +63,14 @@ for size in $PROGRAMS; do
6363
rm -f "$TMP_DIR/proof.bin"
6464

6565
# Parse absolute heap values (second-to-last column) from HEAP PROFILE section
66-
HEAP_VALS=$(awk '/^=== HEAP PROFILE/,/^─/{
66+
HEAP_VALS=$(awk '/^=== HEAP PROFILE/,/^ ─/{
6767
if (/After execute/) printf "execute=%s\n", $(NF-1)
6868
if (/After trace build/) printf "trace_build=%s\n", $(NF-1)
6969
if (/After AIR/) printf "air=%s\n", $(NF-1)
7070
if (/after pool alloc/) printf "pool_alloc=%s\n", $(NF-1)
7171
if (/after main commits/) printf "main_commits=%s\n", $(NF-1)
7272
if (/after aux build/) printf "aux_build=%s\n", $(NF-1)
7373
if (/after aux commit/) printf "aux_commit=%s\n", $(NF-1)
74-
if (/after rounds 2-4/) printf "rounds_2_4=%s\n", $(NF-1)
7574
}' "$STDERR")
7675

7776
PEAK=$(grep -o 'Peak heap: [0-9]*' "$STDOUT" | awk '{print $3}')
@@ -104,7 +103,6 @@ for phase in $PHASES; do
104103
main_commits) label="Main commits" ;;
105104
aux_build) label="Aux build" ;;
106105
aux_commit) label="Aux commit" ;;
107-
rounds_2_4) label="Rounds 2-4" ;;
108106
esac
109107

110108
printf " %-22s" "$label"
@@ -155,7 +153,6 @@ for phase in $PHASES; do
155153
main_commits) label="Main commits" ;;
156154
aux_build) label="Aux build" ;;
157155
aux_commit) label="Aux commit" ;;
158-
rounds_2_4) label="Rounds 2-4" ;;
159156
esac
160157

161158
# Collect (steps_M, delta) pairs
@@ -169,7 +166,6 @@ for phase in $PHASES; do
169166
main_commits) prev_phase_key="pool_alloc" ;;
170167
aux_build) prev_phase_key="main_commits" ;;
171168
aux_commit) prev_phase_key="aux_build" ;;
172-
rounds_2_4) prev_phase_key="aux_commit" ;;
173169
esac
174170

175171
for size in $PROGRAMS; do

0 commit comments

Comments
 (0)