@@ -57,6 +57,7 @@ pub fn print_report(
5757 trace_build : Duration ,
5858 air_construction : Duration ,
5959 total : Duration ,
60+ heap_profile : & stark:: instruments:: ProveHeapProfile ,
6061) {
6162 let mp = stark:: instruments:: take ( ) ;
6263
@@ -69,18 +70,26 @@ pub fn print_report(
6970 row_top ( "Trace build" , trace_build, total) ;
7071 row_top ( "AIR construction" , air_construction, total) ;
7172
72- if let Some ( mp) = mp {
73+ if let Some ( ref mp) = mp {
7374 let round1 = mp. main_commits + mp. aux_build + mp. aux_commit ;
7475
7576 row_top ( "Pre-pass (domains/twiddles)" , mp. prepass , total) ;
7677 row_top ( "Round 1" , round1, total) ;
7778 row_sub ( " Main trace commits" , mp. main_commits , total) ;
78- row_sub ( " expand_columns_to_lde" , mp. round1_sub . main_lde , total) ;
79- row_sub ( " commit (Merkle)" , mp. round1_sub . main_merkle , total) ;
79+ row_sub (
80+ " Main expand_columns_to_lde" ,
81+ mp. round1_sub . main_lde ,
82+ total,
83+ ) ;
84+ row_sub ( " Main commit (Merkle)" , mp. round1_sub . main_merkle , total) ;
8085 row_sub ( " Aux trace build (parallel)" , mp. aux_build , total) ;
8186 row_sub ( " Aux trace commit" , mp. aux_commit , total) ;
82- row_sub ( " expand_columns_to_lde" , mp. round1_sub . aux_lde , total) ;
83- row_sub ( " commit (Merkle)" , mp. round1_sub . aux_merkle , total) ;
87+ row_sub (
88+ " Aux expand_columns_to_lde" ,
89+ mp. round1_sub . aux_lde ,
90+ total,
91+ ) ;
92+ row_sub ( " Aux commit (Merkle)" , mp. round1_sub . aux_merkle , total) ;
8493 row_top ( "Rounds 2\u{2013} 4" , mp. rounds_2_4 , total) ;
8594
8695 // Merge split tables: MEMW[0..4] → MEMW x5
@@ -208,4 +217,33 @@ pub fn print_report(
208217 eprintln ! ( " {}" , "─" . repeat( 58 ) ) ;
209218 eprintln ! ( " {:<36} {:>7.2}s" , "TOTAL" , total. as_secs_f64( ) ) ;
210219 eprintln ! ( ) ;
220+
221+ let mb = |b : usize | b / ( 1024 * 1024 ) ;
222+ if let Some ( before) = heap_profile. before {
223+ eprintln ! ( "=== HEAP PROFILE (MB) ===" ) ;
224+ eprintln ! ( " {:<36} {:>8} {:>8}" , "Phase" , "Heap" , "Delta" ) ;
225+ eprintln ! ( " {}" , "─" . repeat( 56 ) ) ;
226+ let mut prev = before;
227+ let mut print_row = |label : & str , val : Option < usize > | {
228+ if let Some ( v) = val {
229+ let cur = mb ( v) ;
230+ let delta = mb ( v) as isize - mb ( prev) as isize ;
231+ eprintln ! ( " {:<36} {:>7} {:>+8}" , label, cur, delta) ;
232+ prev = v;
233+ }
234+ } ;
235+ print_row ( "After execute" , heap_profile. after_execute ) ;
236+ print_row ( "After trace build" , heap_profile. after_trace_build ) ;
237+ print_row ( "After AIR construction" , heap_profile. after_air ) ;
238+ if let Some ( ref mp_data) = mp {
239+ for ( label, bytes) in & mp_data. heap_snapshots {
240+ let cur = mb ( * bytes) ;
241+ let delta = cur as isize - mb ( prev) as isize ;
242+ eprintln ! ( " {:<36} {:>7} {:>+8}" , label, cur, delta) ;
243+ prev = * bytes;
244+ }
245+ }
246+ eprintln ! ( " {}" , "─" . repeat( 56 ) ) ;
247+ eprintln ! ( ) ;
248+ }
211249}
0 commit comments