@@ -73,6 +73,8 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
73
73
included_modules = tracing:: field:: Empty
74
74
) ;
75
75
76
+ let start = std:: time:: Instant :: now ( ) ;
77
+
76
78
let span = span_outer. clone ( ) ;
77
79
async move {
78
80
let async_module_info = module_graph. async_module_info ( ) . await ?;
@@ -99,6 +101,7 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
99
101
let mut entry_modules =
100
102
FxHashSet :: with_capacity_and_hasher ( module_count, Default :: default ( ) ) ;
101
103
104
+ let inner_span = tracing:: info_span!( "collect mergeable modules" ) ;
102
105
let mergeable = graphs
103
106
. iter ( )
104
107
. flat_map ( |g| g. iter_nodes ( ) )
@@ -113,10 +116,13 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
113
116
Ok ( None )
114
117
} )
115
118
. try_flat_join ( )
119
+ . instrument ( inner_span)
116
120
. await ?
117
121
. into_iter ( )
118
122
. collect :: < FxHashSet < _ > > ( ) ;
119
123
124
+ let inner_span = tracing:: info_span!( "fixed point traversal" ) . entered ( ) ;
125
+
120
126
let mut next_index = 0u32 ;
121
127
let visit_count = module_graph. traverse_edges_fixed_point_with_priority (
122
128
entries. iter ( ) . map ( |e| ( * e, 0 ) ) ,
@@ -197,6 +203,11 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
197
203
|_, _| Ok ( 0 ) ,
198
204
) ?;
199
205
206
+ drop ( inner_span) ;
207
+ let inner_span = tracing:: info_span!( "chunk group collection" ) . entered ( ) ;
208
+
209
+ let after_fixed_point = std:: time:: Instant :: now ( ) ;
210
+
200
211
span. record ( "visit_count" , visit_count) ;
201
212
202
213
#[ derive( Debug , PartialEq , Eq , Hash , PartialOrd , Ord ) ]
@@ -313,6 +324,11 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
313
324
) ?;
314
325
}
315
326
327
+ drop ( inner_span) ;
328
+ let inner_span = tracing:: info_span!( "exposed computation" ) . entered ( ) ;
329
+
330
+ let after_chunk_groups = std:: time:: Instant :: now ( ) ;
331
+
316
332
// We use list.pop() below, so reverse order using negation
317
333
lists_reverse_indices
318
334
. sort_by_cached_key ( |_, b| b. iter ( ) . map ( |o| o. entry ) . min ( ) . map ( |v| -( v as i64 ) ) ) ;
@@ -363,6 +379,8 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
363
379
} ,
364
380
) ?;
365
381
382
+ drop ( inner_span) ;
383
+ let inner_span = tracing:: info_span!( "reconciliation" ) . entered ( ) ;
366
384
while let Some ( ( _, common_occurrences) ) = lists_reverse_indices. pop ( ) {
367
385
if common_occurrences. len ( ) < 2 {
368
386
// Module exists only in one list, no need to split
@@ -485,10 +503,7 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
485
503
lists. push ( after_list. clone ( ) ) ;
486
504
for ( i, & m) in after_list. iter ( ) . enumerate ( ) {
487
505
let Some ( occurrences) = lists_reverse_indices. get_mut ( & m) else {
488
- bail ! (
489
- "Couldn't find module in list {:?}" ,
490
- m. ident( ) . to_string( ) . await ?,
491
- ) ;
506
+ bail ! ( "Couldn't find module in reverse list" ) ;
492
507
} ;
493
508
494
509
let removed = occurrences. swap_remove ( & ListOccurrence {
@@ -509,6 +524,10 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
509
524
// Dedupe the lists
510
525
let lists = lists. into_iter ( ) . collect :: < FxHashSet < _ > > ( ) ;
511
526
527
+ let after_reconcile = std:: time:: Instant :: now ( ) ;
528
+
529
+ drop ( inner_span) ;
530
+ let inner_span = tracing:: info_span!( "merging" ) ;
512
531
// Call MergeableModule impl to merge the modules.
513
532
let result = lists
514
533
. into_iter ( )
@@ -570,6 +589,7 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
570
589
) ) )
571
590
} )
572
591
. try_join ( )
592
+ . instrument ( inner_span)
573
593
. await ?;
574
594
575
595
#[ allow( clippy:: type_complexity) ]
@@ -593,6 +613,23 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
593
613
span. record ( "merged_groups" , replacements. len ( ) ) ;
594
614
span. record ( "included_modules" , included. len ( ) ) ;
595
615
616
+ let end = std:: time:: Instant :: now ( ) ;
617
+
618
+ println ! (
619
+ "Merged modules groups in {} ms (fixed_point: {}, chunk_groups: {}, reconcile: {}), \
620
+ {} modules, {} visits",
621
+ after_fixed_point. duration_since( start) . as_millis( ) ,
622
+ after_chunk_groups
623
+ . duration_since( after_fixed_point)
624
+ . as_millis( ) ,
625
+ after_reconcile
626
+ . duration_since( after_chunk_groups)
627
+ . as_millis( ) ,
628
+ end. duration_since( start) . as_millis( ) ,
629
+ module_count,
630
+ visit_count
631
+ ) ;
632
+
596
633
Ok ( MergedModuleInfo {
597
634
replacements,
598
635
replacements_to_original,
0 commit comments