@@ -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
/*
@@ -248,6 +252,8 @@ static void fscache_clear(void)
248
252
{
249
253
hashmap_free (& map , 1 );
250
254
hashmap_init (& map , (hashmap_cmp_fn )fsentry_cmp , NULL , 0 );
255
+ lstat_requests = opendir_requests = 0 ;
256
+ fscache_misses = fscache_requests = 0 ;
251
257
}
252
258
253
259
/*
@@ -294,6 +300,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
294
300
int dir_not_found ;
295
301
296
302
EnterCriticalSection (& mutex );
303
+ fscache_requests ++ ;
297
304
/* check if entry is in cache */
298
305
fse = fscache_get_wait (key );
299
306
if (fse ) {
@@ -356,6 +363,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
356
363
}
357
364
358
365
/* add directory listing to the cache */
366
+ fscache_misses ++ ;
359
367
fscache_add (fse );
360
368
361
369
/* lookup file entry if requested (fse already points to directory) */
@@ -393,6 +401,8 @@ int fscache_enable(int enable)
393
401
return 0 ;
394
402
395
403
InitializeCriticalSection (& mutex );
404
+ lstat_requests = opendir_requests = 0 ;
405
+ fscache_misses = fscache_requests = 0 ;
396
406
hashmap_init (& map , (hashmap_cmp_fn ) fsentry_cmp , NULL , 0 );
397
407
initialized = 1 ;
398
408
}
@@ -409,6 +419,10 @@ int fscache_enable(int enable)
409
419
opendir = dirent_opendir ;
410
420
lstat = mingw_lstat ;
411
421
EnterCriticalSection (& mutex );
422
+ trace_printf_key (& trace_fscache , "fscache: lstat %u, opendir %u, "
423
+ "total requests/misses %u/%u\n" ,
424
+ lstat_requests , opendir_requests ,
425
+ fscache_requests , fscache_misses );
412
426
fscache_clear ();
413
427
LeaveCriticalSection (& mutex );
414
428
}
@@ -428,6 +442,7 @@ int fscache_lstat(const char *filename, struct stat *st)
428
442
if (!fscache_enabled (filename ))
429
443
return mingw_lstat (filename , st );
430
444
445
+ lstat_requests ++ ;
431
446
/* split filename into path + name */
432
447
len = strlen (filename );
433
448
if (len && is_dir_sep (filename [len - 1 ]))
@@ -507,6 +522,7 @@ DIR *fscache_opendir(const char *dirname)
507
522
if (!fscache_enabled (dirname ))
508
523
return dirent_opendir (dirname );
509
524
525
+ opendir_requests ++ ;
510
526
/* prepare name (strip trailing '/', replace '.') */
511
527
len = strlen (dirname );
512
528
if ((len == 1 && dirname [0 ] == '.' ) ||
0 commit comments