@@ -11,6 +11,10 @@ static int initialized;
1111static volatile long enabled ;
1212static struct hashmap map ;
1313static CRITICAL_SECTION mutex ;
14+ static unsigned int lstat_requests ;
15+ static unsigned int opendir_requests ;
16+ static unsigned int fscache_requests ;
17+ static unsigned int fscache_misses ;
1418static struct trace_key trace_fscache = TRACE_KEY_INIT (FSCACHE );
1519
1620/*
@@ -270,6 +274,8 @@ static void fscache_clear(void)
270274{
271275 hashmap_clear_and_free (& map , struct fsentry , ent );
272276 hashmap_init (& map , (hashmap_cmp_fn )fsentry_cmp , NULL , 0 );
277+ lstat_requests = opendir_requests = 0 ;
278+ fscache_misses = fscache_requests = 0 ;
273279}
274280
275281/*
@@ -316,6 +322,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
316322 int dir_not_found ;
317323
318324 EnterCriticalSection (& mutex );
325+ fscache_requests ++ ;
319326 /* check if entry is in cache */
320327 fse = fscache_get_wait (key );
321328 if (fse ) {
@@ -379,6 +386,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
379386 }
380387
381388 /* add directory listing to the cache */
389+ fscache_misses ++ ;
382390 fscache_add (fse );
383391
384392 /* lookup file entry if requested (fse already points to directory) */
@@ -416,6 +424,8 @@ int fscache_enable(int enable)
416424 return 0 ;
417425
418426 InitializeCriticalSection (& mutex );
427+ lstat_requests = opendir_requests = 0 ;
428+ fscache_misses = fscache_requests = 0 ;
419429 hashmap_init (& map , (hashmap_cmp_fn ) fsentry_cmp , NULL , 0 );
420430 initialized = 1 ;
421431 }
@@ -432,6 +442,10 @@ int fscache_enable(int enable)
432442 opendir = dirent_opendir ;
433443 lstat = mingw_lstat ;
434444 EnterCriticalSection (& mutex );
445+ trace_printf_key (& trace_fscache , "fscache: lstat %u, opendir %u, "
446+ "total requests/misses %u/%u\n" ,
447+ lstat_requests , opendir_requests ,
448+ fscache_requests , fscache_misses );
435449 fscache_clear ();
436450 LeaveCriticalSection (& mutex );
437451 }
@@ -469,6 +483,7 @@ int fscache_lstat(const char *filename, struct stat *st)
469483 if (!fscache_enabled (filename ))
470484 return mingw_lstat (filename , st );
471485
486+ lstat_requests ++ ;
472487 /* split filename into path + name */
473488 len = strlen (filename );
474489 if (len && is_dir_sep (filename [len - 1 ]))
@@ -550,6 +565,7 @@ DIR *fscache_opendir(const char *dirname)
550565 if (!fscache_enabled (dirname ))
551566 return dirent_opendir (dirname );
552567
568+ opendir_requests ++ ;
553569 /* prepare name (strip trailing '/', replace '.') */
554570 len = strlen (dirname );
555571 if ((len == 1 && dirname [0 ] == '.' ) ||
0 commit comments