@@ -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,18 +71,18 @@ 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) ;
7678 row_top ( "Round 1" , round1, total) ;
7779 row_sub ( " Main trace commits" , mp. main_commits , total) ;
78- row_sub ( " expand_pool_to_lde" , mp. round1_sub . main_lde , total) ;
79- row_sub ( " commit (Merkle)" , mp. round1_sub . main_merkle , total) ;
80+ row_sub ( " Main expand_pool_to_lde" , mp. round1_sub . main_lde , total) ;
81+ row_sub ( " Main commit (Merkle)" , mp. round1_sub . main_merkle , total) ;
8082 row_sub ( " Aux trace build (parallel)" , mp. aux_build , total) ;
8183 row_sub ( " Aux trace commit" , mp. aux_commit , total) ;
82- row_sub ( " expand_pool_to_lde" , mp. round1_sub . aux_lde , total) ;
83- row_sub ( " commit (Merkle)" , mp. round1_sub . aux_merkle , total) ;
84+ row_sub ( " Aux expand_pool_to_lde" , mp. round1_sub . aux_lde , total) ;
85+ row_sub ( " Aux commit (Merkle)" , mp. round1_sub . aux_merkle , total) ;
8486 row_top ( "Rounds 2\u{2013} 4" , mp. rounds_2_4 , total) ;
8587
8688 // Merge split tables: MEMW[0..4] → MEMW x5
@@ -214,4 +216,33 @@ pub fn print_report(
214216 eprintln ! ( " {}" , "─" . repeat( 58 ) ) ;
215217 eprintln ! ( " {:<36} {:>7.2}s" , "TOTAL" , total. as_secs_f64( ) ) ;
216218 eprintln ! ( ) ;
219+
220+ let mb = |b : usize | b / ( 1024 * 1024 ) ;
221+ if let Some ( before) = heap_before {
222+ eprintln ! ( "=== HEAP PROFILE (MB) ===" ) ;
223+ eprintln ! ( " {:<36} {:>8} {:>8}" , "Phase" , "Heap" , "Delta" ) ;
224+ eprintln ! ( " {}" , "─" . repeat( 56 ) ) ;
225+ let mut prev = before;
226+ let mut print_row = |label : & str , val : Option < usize > | {
227+ if let Some ( v) = val {
228+ let cur = mb ( v) ;
229+ let delta = mb ( v) as isize - mb ( prev) as isize ;
230+ eprintln ! ( " {:<36} {:>7} {:>+8}" , label, cur, delta) ;
231+ prev = v;
232+ }
233+ } ;
234+ print_row ( "After execute" , heap_profile. after_execute ) ;
235+ print_row ( "After trace build" , heap_profile. after_trace_build ) ;
236+ print_row ( "After AIR construction" , heap_profile. after_air ) ;
237+ if let Some ( ref mp_data) = mp {
238+ for ( label, bytes) in & mp_data. heap_snapshots {
239+ let cur = mb ( * bytes) ;
240+ let delta = cur as isize - mb ( prev) as isize ;
241+ eprintln ! ( " {:<36} {:>7} {:>+8}" , label, cur, delta) ;
242+ prev = * bytes;
243+ }
244+ }
245+ eprintln ! ( " {}" , "─" . repeat( 56 ) ) ;
246+ eprintln ! ( ) ;
247+ }
217248}
0 commit comments