@@ -57,6 +57,8 @@ pub fn print_report(
5757 trace_build : Duration ,
5858 air_construction : Duration ,
5959 total : Duration ,
60+ heap_before : Option < usize > ,
61+ heap_profile : & stark:: instruments:: ProveHeapProfile ,
6062) {
6163 let mp = stark:: instruments:: take ( ) ;
6264
@@ -69,7 +71,7 @@ pub fn print_report(
6971 row_top ( "Trace build" , trace_build, total) ;
7072 row_top ( "AIR construction" , air_construction, total) ;
7173
72- if let Some ( mp) = mp {
74+ if let Some ( ref mp) = mp {
7375 let round1 = mp. main_commits + mp. aux_build + mp. aux_commit ;
7476
7577 row_top ( "Pre-pass (domains/twiddles)" , mp. prepass , total) ;
@@ -177,10 +179,7 @@ pub fn print_report(
177179 ( "R4 queries & openings" , total_queries) ,
178180 ] ;
179181 sub_ops. sort_by ( |a, b| b. 1 . cmp ( & a. 1 ) ) ;
180- eprintln ! (
181- " {}" ,
182- " \u{2500} \u{2500} sub-operation totals (all tables) \u{2500} \u{2500} " ,
183- ) ;
182+ eprintln ! ( " \u{2500} \u{2500} sub-operation totals (all tables) \u{2500} \u{2500} " , ) ;
184183 for ( label, dur) in & sub_ops {
185184 row_sub ( & format ! ( " {label}" ) , * dur, total) ;
186185 }
@@ -214,4 +213,34 @@ pub fn print_report(
214213 eprintln ! ( " {}" , "─" . repeat( 58 ) ) ;
215214 eprintln ! ( " {:<36} {:>7.2}s" , "TOTAL" , total. as_secs_f64( ) ) ;
216215 eprintln ! ( ) ;
216+
217+ let mb = |b : usize | b / ( 1024 * 1024 ) ;
218+ if let Some ( before) = heap_before {
219+ eprintln ! ( "=== HEAP PROFILE (MB) ===" ) ;
220+ eprintln ! ( " {:<36} {:>8} {:>8}" , "Phase" , "Heap" , "Delta" ) ;
221+ eprintln ! ( " {}" , "─" . repeat( 56 ) ) ;
222+ let mut prev = before;
223+ let mut print_row = |label : & str , val : Option < usize > | {
224+ if let Some ( v) = val {
225+ let cur = mb ( v) ;
226+ let delta = mb ( v) as isize - mb ( prev) as isize ;
227+ eprintln ! ( " {:<36} {:>7} {:>+8}" , label, cur, delta) ;
228+ prev = v;
229+ }
230+ } ;
231+ print_row ( "After execute" , heap_profile. after_execute ) ;
232+ print_row ( "After trace build" , heap_profile. after_trace_build ) ;
233+ print_row ( "After AIR construction" , heap_profile. after_air ) ;
234+ 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;
238+ let delta = cur as isize - mb ( prev) as isize ;
239+ eprintln ! ( " {:<36} {:>7} {:>+8}" , label, cur, delta) ;
240+ prev = snap_bytes;
241+ }
242+ }
243+ eprintln ! ( " {}" , "─" . repeat( 56 ) ) ;
244+ eprintln ! ( ) ;
245+ }
217246}
0 commit comments