@@ -8,6 +8,10 @@ static int initialized;
88static volatile long enabled ;
99static struct hashmap map ;
1010static CRITICAL_SECTION mutex ;
11+ static unsigned int lstat_requests ;
12+ static unsigned int opendir_requests ;
13+ static unsigned int fscache_requests ;
14+ static unsigned int fscache_misses ;
1115static struct trace_key trace_fscache = TRACE_KEY_INIT (FSCACHE );
1216
1317/*
@@ -247,6 +251,8 @@ static void fscache_clear(void)
247251{
248252 hashmap_free (& map , 1 );
249253 hashmap_init (& map , (hashmap_cmp_fn )fsentry_cmp , NULL , 0 );
254+ lstat_requests = opendir_requests = 0 ;
255+ fscache_misses = fscache_requests = 0 ;
250256}
251257
252258/*
@@ -293,6 +299,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
293299 int dir_not_found ;
294300
295301 EnterCriticalSection (& mutex );
302+ fscache_requests ++ ;
296303 /* check if entry is in cache */
297304 fse = fscache_get_wait (key );
298305 if (fse ) {
@@ -355,6 +362,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
355362 }
356363
357364 /* add directory listing to the cache */
365+ fscache_misses ++ ;
358366 fscache_add (fse );
359367
360368 /* lookup file entry if requested (fse already points to directory) */
@@ -392,6 +400,8 @@ int fscache_enable(int enable)
392400 return 0 ;
393401
394402 InitializeCriticalSection (& mutex );
403+ lstat_requests = opendir_requests = 0 ;
404+ fscache_misses = fscache_requests = 0 ;
395405 hashmap_init (& map , (hashmap_cmp_fn ) fsentry_cmp , NULL , 0 );
396406 initialized = 1 ;
397407 }
@@ -408,6 +418,10 @@ int fscache_enable(int enable)
408418 opendir = dirent_opendir ;
409419 lstat = mingw_lstat ;
410420 EnterCriticalSection (& mutex );
421+ trace_printf_key (& trace_fscache , "fscache: lstat %u, opendir %u, "
422+ "total requests/misses %u/%u\n" ,
423+ lstat_requests , opendir_requests ,
424+ fscache_requests , fscache_misses );
411425 fscache_clear ();
412426 LeaveCriticalSection (& mutex );
413427 }
@@ -439,6 +453,7 @@ int fscache_lstat(const char *filename, struct stat *st)
439453 if (!fscache_enabled (filename ))
440454 return mingw_lstat (filename , st );
441455
456+ lstat_requests ++ ;
442457 /* split filename into path + name */
443458 len = strlen (filename );
444459 if (len && is_dir_sep (filename [len - 1 ]))
@@ -518,6 +533,7 @@ DIR *fscache_opendir(const char *dirname)
518533 if (!fscache_enabled (dirname ))
519534 return dirent_opendir (dirname );
520535
536+ opendir_requests ++ ;
521537 /* prepare name (strip trailing '/', replace '.') */
522538 len = strlen (dirname );
523539 if ((len == 1 && dirname [0 ] == '.' ) ||
0 commit comments