@@ -11,6 +11,10 @@ static int initialized;
11
11
static volatile long enabled ;
12
12
static struct hashmap map ;
13
13
static 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 ;
14
18
static struct trace_key trace_fscache = TRACE_KEY_INIT (FSCACHE );
15
19
16
20
/*
@@ -270,6 +274,8 @@ static void fscache_clear(void)
270
274
{
271
275
hashmap_clear_and_free (& map , struct fsentry , ent );
272
276
hashmap_init (& map , (hashmap_cmp_fn )fsentry_cmp , NULL , 0 );
277
+ lstat_requests = opendir_requests = 0 ;
278
+ fscache_misses = fscache_requests = 0 ;
273
279
}
274
280
275
281
/*
@@ -316,6 +322,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
316
322
int dir_not_found ;
317
323
318
324
EnterCriticalSection (& mutex );
325
+ fscache_requests ++ ;
319
326
/* check if entry is in cache */
320
327
fse = fscache_get_wait (key );
321
328
if (fse ) {
@@ -379,6 +386,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
379
386
}
380
387
381
388
/* add directory listing to the cache */
389
+ fscache_misses ++ ;
382
390
fscache_add (fse );
383
391
384
392
/* lookup file entry if requested (fse already points to directory) */
@@ -416,6 +424,8 @@ int fscache_enable(int enable)
416
424
return 0 ;
417
425
418
426
InitializeCriticalSection (& mutex );
427
+ lstat_requests = opendir_requests = 0 ;
428
+ fscache_misses = fscache_requests = 0 ;
419
429
hashmap_init (& map , (hashmap_cmp_fn ) fsentry_cmp , NULL , 0 );
420
430
initialized = 1 ;
421
431
}
@@ -432,6 +442,10 @@ int fscache_enable(int enable)
432
442
opendir = dirent_opendir ;
433
443
lstat = mingw_lstat ;
434
444
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 );
435
449
fscache_clear ();
436
450
LeaveCriticalSection (& mutex );
437
451
}
@@ -469,6 +483,7 @@ int fscache_lstat(const char *filename, struct stat *st)
469
483
if (!fscache_enabled (filename ))
470
484
return mingw_lstat (filename , st );
471
485
486
+ lstat_requests ++ ;
472
487
/* split filename into path + name */
473
488
len = strlen (filename );
474
489
if (len && is_dir_sep (filename [len - 1 ]))
@@ -550,6 +565,7 @@ DIR *fscache_opendir(const char *dirname)
550
565
if (!fscache_enabled (dirname ))
551
566
return dirent_opendir (dirname );
552
567
568
+ opendir_requests ++ ;
553
569
/* prepare name (strip trailing '/', replace '.') */
554
570
len = strlen (dirname );
555
571
if ((len == 1 && dirname [0 ] == '.' ) ||
0 commit comments