@@ -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/*
@@ -271,6 +275,8 @@ static void fscache_clear(void)
271275{
272276 hashmap_free (& map , 1 );
273277 hashmap_init (& map , (hashmap_cmp_fn )fsentry_cmp , NULL , 0 );
278+ lstat_requests = opendir_requests = 0 ;
279+ fscache_misses = fscache_requests = 0 ;
274280}
275281
276282/*
@@ -317,6 +323,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
317323 int dir_not_found ;
318324
319325 EnterCriticalSection (& mutex );
326+ fscache_requests ++ ;
320327 /* check if entry is in cache */
321328 fse = fscache_get_wait (key );
322329 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 }
@@ -463,6 +477,7 @@ int fscache_lstat(const char *filename, struct stat *st)
463477 if (!fscache_enabled (filename ))
464478 return mingw_lstat (filename , st );
465479
480+ lstat_requests ++ ;
466481 /* split filename into path + name */
467482 len = strlen (filename );
468483 if (len && is_dir_sep (filename [len - 1 ]))
@@ -543,6 +558,7 @@ DIR *fscache_opendir(const char *dirname)
543558 if (!fscache_enabled (dirname ))
544559 return dirent_opendir (dirname );
545560
561+ opendir_requests ++ ;
546562 /* prepare name (strip trailing '/', replace '.') */
547563 len = strlen (dirname );
548564 if ((len == 1 && dirname [0 ] == '.' ) ||
0 commit comments