@@ -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/*
@@ -265,6 +269,8 @@ static void fscache_clear(void)
265269{
266270 hashmap_clear_and_free (& map , struct fsentry , ent );
267271 hashmap_init (& map , (hashmap_cmp_fn )fsentry_cmp , NULL , 0 );
272+ lstat_requests = opendir_requests = 0 ;
273+ fscache_misses = fscache_requests = 0 ;
268274}
269275
270276/*
@@ -311,6 +317,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
311317 int dir_not_found ;
312318
313319 EnterCriticalSection (& mutex );
320+ fscache_requests ++ ;
314321 /* check if entry is in cache */
315322 fse = fscache_get_wait (key );
316323 if (fse ) {
@@ -374,6 +381,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
374381 }
375382
376383 /* add directory listing to the cache */
384+ fscache_misses ++ ;
377385 fscache_add (fse );
378386
379387 /* lookup file entry if requested (fse already points to directory) */
@@ -411,6 +419,8 @@ int fscache_enable(int enable)
411419 return 0 ;
412420
413421 InitializeCriticalSection (& mutex );
422+ lstat_requests = opendir_requests = 0 ;
423+ fscache_misses = fscache_requests = 0 ;
414424 hashmap_init (& map , (hashmap_cmp_fn ) fsentry_cmp , NULL , 0 );
415425 initialized = 1 ;
416426 }
@@ -427,6 +437,10 @@ int fscache_enable(int enable)
427437 opendir = dirent_opendir ;
428438 lstat = mingw_lstat ;
429439 EnterCriticalSection (& mutex );
440+ trace_printf_key (& trace_fscache , "fscache: lstat %u, opendir %u, "
441+ "total requests/misses %u/%u\n" ,
442+ lstat_requests , opendir_requests ,
443+ fscache_requests , fscache_misses );
430444 fscache_clear ();
431445 LeaveCriticalSection (& mutex );
432446 }
@@ -459,6 +473,7 @@ int fscache_lstat(const char *filename, struct stat *st)
459473 if (!fscache_enabled (filename ))
460474 return mingw_lstat (filename , st );
461475
476+ lstat_requests ++ ;
462477 /* split filename into path + name */
463478 len = strlen (filename );
464479 if (len && is_dir_sep (filename [len - 1 ]))
@@ -540,6 +555,7 @@ DIR *fscache_opendir(const char *dirname)
540555 if (!fscache_enabled (dirname ))
541556 return dirent_opendir (dirname );
542557
558+ opendir_requests ++ ;
543559 /* prepare name (strip trailing '/', replace '.') */
544560 len = strlen (dirname );
545561 if ((len == 1 && dirname [0 ] == '.' ) ||
0 commit comments