@@ -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
/*
@@ -262,6 +266,8 @@ static void fscache_clear(void)
262
266
{
263
267
hashmap_free (& map , 1 );
264
268
hashmap_init (& map , (hashmap_cmp_fn )fsentry_cmp , NULL , 0 );
269
+ lstat_requests = opendir_requests = 0 ;
270
+ fscache_misses = fscache_requests = 0 ;
265
271
}
266
272
267
273
/*
@@ -308,6 +314,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
308
314
int dir_not_found ;
309
315
310
316
EnterCriticalSection (& mutex );
317
+ fscache_requests ++ ;
311
318
/* check if entry is in cache */
312
319
fse = fscache_get_wait (key );
313
320
if (fse ) {
@@ -370,6 +377,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
370
377
}
371
378
372
379
/* add directory listing to the cache */
380
+ fscache_misses ++ ;
373
381
fscache_add (fse );
374
382
375
383
/* lookup file entry if requested (fse already points to directory) */
@@ -407,6 +415,8 @@ int fscache_enable(int enable)
407
415
return 0 ;
408
416
409
417
InitializeCriticalSection (& mutex );
418
+ lstat_requests = opendir_requests = 0 ;
419
+ fscache_misses = fscache_requests = 0 ;
410
420
hashmap_init (& map , (hashmap_cmp_fn ) fsentry_cmp , NULL , 0 );
411
421
initialized = 1 ;
412
422
}
@@ -423,6 +433,10 @@ int fscache_enable(int enable)
423
433
opendir = dirent_opendir ;
424
434
lstat = mingw_lstat ;
425
435
EnterCriticalSection (& mutex );
436
+ trace_printf_key (& trace_fscache , "fscache: lstat %u, opendir %u, "
437
+ "total requests/misses %u/%u\n" ,
438
+ lstat_requests , opendir_requests ,
439
+ fscache_requests , fscache_misses );
426
440
fscache_clear ();
427
441
LeaveCriticalSection (& mutex );
428
442
}
@@ -454,6 +468,7 @@ int fscache_lstat(const char *filename, struct stat *st)
454
468
if (!fscache_enabled (filename ))
455
469
return mingw_lstat (filename , st );
456
470
471
+ lstat_requests ++ ;
457
472
/* split filename into path + name */
458
473
len = strlen (filename );
459
474
if (len && is_dir_sep (filename [len - 1 ]))
@@ -534,6 +549,7 @@ DIR *fscache_opendir(const char *dirname)
534
549
if (!fscache_enabled (dirname ))
535
550
return dirent_opendir (dirname );
536
551
552
+ opendir_requests ++ ;
537
553
/* prepare name (strip trailing '/', replace '.') */
538
554
len = strlen (dirname );
539
555
if ((len == 1 && dirname [0 ] == '.' ) ||
0 commit comments