@@ -8,6 +8,10 @@ static int initialized;
8
8
static volatile long enabled ;
9
9
static struct hashmap map ;
10
10
static 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 ;
11
15
static struct trace_key trace_fscache = TRACE_KEY_INIT (FSCACHE );
12
16
13
17
/*
@@ -271,6 +275,8 @@ static void fscache_clear(void)
271
275
{
272
276
hashmap_free (& map , 1 );
273
277
hashmap_init (& map , (hashmap_cmp_fn )fsentry_cmp , NULL , 0 );
278
+ lstat_requests = opendir_requests = 0 ;
279
+ fscache_misses = fscache_requests = 0 ;
274
280
}
275
281
276
282
/*
@@ -317,6 +323,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
317
323
int dir_not_found ;
318
324
319
325
EnterCriticalSection (& mutex );
326
+ fscache_requests ++ ;
320
327
/* check if entry is in cache */
321
328
fse = fscache_get_wait (key );
322
329
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
}
@@ -463,6 +477,7 @@ int fscache_lstat(const char *filename, struct stat *st)
463
477
if (!fscache_enabled (filename ))
464
478
return mingw_lstat (filename , st );
465
479
480
+ lstat_requests ++ ;
466
481
/* split filename into path + name */
467
482
len = strlen (filename );
468
483
if (len && is_dir_sep (filename [len - 1 ]))
@@ -543,6 +558,7 @@ DIR *fscache_opendir(const char *dirname)
543
558
if (!fscache_enabled (dirname ))
544
559
return dirent_opendir (dirname );
545
560
561
+ opendir_requests ++ ;
546
562
/* prepare name (strip trailing '/', replace '.') */
547
563
len = strlen (dirname );
548
564
if ((len == 1 && dirname [0 ] == '.' ) ||
0 commit comments