@@ -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
/*
@@ -257,6 +261,8 @@ static void fscache_clear(void)
257
261
{
258
262
hashmap_free_entries (& map , struct fsentry , ent );
259
263
hashmap_init (& map , (hashmap_cmp_fn )fsentry_cmp , NULL , 0 );
264
+ lstat_requests = opendir_requests = 0 ;
265
+ fscache_misses = fscache_requests = 0 ;
260
266
}
261
267
262
268
/*
@@ -303,6 +309,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
303
309
int dir_not_found ;
304
310
305
311
EnterCriticalSection (& mutex );
312
+ fscache_requests ++ ;
306
313
/* check if entry is in cache */
307
314
fse = fscache_get_wait (key );
308
315
if (fse ) {
@@ -366,6 +373,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
366
373
}
367
374
368
375
/* add directory listing to the cache */
376
+ fscache_misses ++ ;
369
377
fscache_add (fse );
370
378
371
379
/* lookup file entry if requested (fse already points to directory) */
@@ -403,6 +411,8 @@ int fscache_enable(int enable)
403
411
return 0 ;
404
412
405
413
InitializeCriticalSection (& mutex );
414
+ lstat_requests = opendir_requests = 0 ;
415
+ fscache_misses = fscache_requests = 0 ;
406
416
hashmap_init (& map , (hashmap_cmp_fn ) fsentry_cmp , NULL , 0 );
407
417
initialized = 1 ;
408
418
}
@@ -419,6 +429,10 @@ int fscache_enable(int enable)
419
429
opendir = dirent_opendir ;
420
430
lstat = mingw_lstat ;
421
431
EnterCriticalSection (& mutex );
432
+ trace_printf_key (& trace_fscache , "fscache: lstat %u, opendir %u, "
433
+ "total requests/misses %u/%u\n" ,
434
+ lstat_requests , opendir_requests ,
435
+ fscache_requests , fscache_misses );
422
436
fscache_clear ();
423
437
LeaveCriticalSection (& mutex );
424
438
}
@@ -451,6 +465,7 @@ int fscache_lstat(const char *filename, struct stat *st)
451
465
if (!fscache_enabled (filename ))
452
466
return mingw_lstat (filename , st );
453
467
468
+ lstat_requests ++ ;
454
469
/* split filename into path + name */
455
470
len = strlen (filename );
456
471
if (len && is_dir_sep (filename [len - 1 ]))
@@ -530,6 +545,7 @@ DIR *fscache_opendir(const char *dirname)
530
545
if (!fscache_enabled (dirname ))
531
546
return dirent_opendir (dirname );
532
547
548
+ opendir_requests ++ ;
533
549
/* prepare name (strip trailing '/', replace '.') */
534
550
len = strlen (dirname );
535
551
if ((len == 1 && dirname [0 ] == '.' ) ||
0 commit comments