@@ -2751,15 +2751,46 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d
2751
2751
return root ;
2752
2752
}
2753
2753
2754
+ static void emit_traversal_statistics (struct dir_struct * dir ,
2755
+ struct repository * repo ,
2756
+ const char * path ,
2757
+ int path_len )
2758
+ {
2759
+ if (!trace2_is_enabled ())
2760
+ return ;
2761
+
2762
+ if (!path_len ) {
2763
+ trace2_data_string ("read_directory" , repo , "path" , "" );
2764
+ } else {
2765
+ struct strbuf tmp = STRBUF_INIT ;
2766
+ strbuf_add (& tmp , path , path_len );
2767
+ trace2_data_string ("read_directory" , repo , "path" , tmp .buf );
2768
+ strbuf_release (& tmp );
2769
+ }
2770
+
2771
+ if (!dir -> untracked )
2772
+ return ;
2773
+ trace2_data_intmax ("read_directory" , repo ,
2774
+ "node-creation" , dir -> untracked -> dir_created );
2775
+ trace2_data_intmax ("read_directory" , repo ,
2776
+ "gitignore-invalidation" ,
2777
+ dir -> untracked -> gitignore_invalidated );
2778
+ trace2_data_intmax ("read_directory" , repo ,
2779
+ "directory-invalidation" ,
2780
+ dir -> untracked -> dir_invalidated );
2781
+ trace2_data_intmax ("read_directory" , repo ,
2782
+ "opendir" , dir -> untracked -> dir_opened );
2783
+ }
2784
+
2754
2785
int read_directory (struct dir_struct * dir , struct index_state * istate ,
2755
2786
const char * path , int len , const struct pathspec * pathspec )
2756
2787
{
2757
2788
struct untracked_cache_dir * untracked ;
2758
2789
2759
- trace_performance_enter ( );
2790
+ trace2_region_enter ( "dir" , "read_directory" , istate -> repo );
2760
2791
2761
2792
if (has_symlink_leading_path (path , len )) {
2762
- trace_performance_leave ( "read directory %.*s " , len , path );
2793
+ trace2_region_leave ( "dir " , "read_directory" , istate -> repo );
2763
2794
return dir -> nr ;
2764
2795
}
2765
2796
@@ -2775,23 +2806,15 @@ int read_directory(struct dir_struct *dir, struct index_state *istate,
2775
2806
QSORT (dir -> entries , dir -> nr , cmp_dir_entry );
2776
2807
QSORT (dir -> ignored , dir -> ignored_nr , cmp_dir_entry );
2777
2808
2778
- trace_performance_leave ("read directory %.*s" , len , path );
2809
+ emit_traversal_statistics (dir , istate -> repo , path , len );
2810
+
2811
+ trace2_region_leave ("dir" , "read_directory" , istate -> repo );
2779
2812
if (dir -> untracked ) {
2780
2813
static int force_untracked_cache = -1 ;
2781
- static struct trace_key trace_untracked_stats = TRACE_KEY_INIT (UNTRACKED_STATS );
2782
2814
2783
2815
if (force_untracked_cache < 0 )
2784
2816
force_untracked_cache =
2785
2817
git_env_bool ("GIT_FORCE_UNTRACKED_CACHE" , 0 );
2786
- trace_printf_key (& trace_untracked_stats ,
2787
- "node creation: %u\n"
2788
- "gitignore invalidation: %u\n"
2789
- "directory invalidation: %u\n"
2790
- "opendir: %u\n" ,
2791
- dir -> untracked -> dir_created ,
2792
- dir -> untracked -> gitignore_invalidated ,
2793
- dir -> untracked -> dir_invalidated ,
2794
- dir -> untracked -> dir_opened );
2795
2818
if (force_untracked_cache &&
2796
2819
dir -> untracked == istate -> untracked &&
2797
2820
(dir -> untracked -> dir_opened ||
@@ -2802,6 +2825,7 @@ int read_directory(struct dir_struct *dir, struct index_state *istate,
2802
2825
FREE_AND_NULL (dir -> untracked );
2803
2826
}
2804
2827
}
2828
+
2805
2829
return dir -> nr ;
2806
2830
}
2807
2831
0 commit comments