@@ -9,6 +9,10 @@ static int initialized;
9
9
static volatile long enabled ;
10
10
static struct hashmap map ;
11
11
static CRITICAL_SECTION mutex ;
12
+ static unsigned int lstat_requests ;
13
+ static unsigned int opendir_requests ;
14
+ static unsigned int fscache_requests ;
15
+ static unsigned int fscache_misses ;
12
16
static struct trace_key trace_fscache = TRACE_KEY_INIT (FSCACHE );
13
17
14
18
/*
@@ -263,6 +267,8 @@ static void fscache_clear(void)
263
267
{
264
268
hashmap_clear_and_free (& map , struct fsentry , ent );
265
269
hashmap_init (& map , (hashmap_cmp_fn )fsentry_cmp , NULL , 0 );
270
+ lstat_requests = opendir_requests = 0 ;
271
+ fscache_misses = fscache_requests = 0 ;
266
272
}
267
273
268
274
/*
@@ -309,6 +315,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
309
315
int dir_not_found ;
310
316
311
317
EnterCriticalSection (& mutex );
318
+ fscache_requests ++ ;
312
319
/* check if entry is in cache */
313
320
fse = fscache_get_wait (key );
314
321
if (fse ) {
@@ -372,6 +379,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
372
379
}
373
380
374
381
/* add directory listing to the cache */
382
+ fscache_misses ++ ;
375
383
fscache_add (fse );
376
384
377
385
/* lookup file entry if requested (fse already points to directory) */
@@ -409,6 +417,8 @@ int fscache_enable(int enable)
409
417
return 0 ;
410
418
411
419
InitializeCriticalSection (& mutex );
420
+ lstat_requests = opendir_requests = 0 ;
421
+ fscache_misses = fscache_requests = 0 ;
412
422
hashmap_init (& map , (hashmap_cmp_fn ) fsentry_cmp , NULL , 0 );
413
423
initialized = 1 ;
414
424
}
@@ -425,6 +435,10 @@ int fscache_enable(int enable)
425
435
opendir = dirent_opendir ;
426
436
lstat = mingw_lstat ;
427
437
EnterCriticalSection (& mutex );
438
+ trace_printf_key (& trace_fscache , "fscache: lstat %u, opendir %u, "
439
+ "total requests/misses %u/%u\n" ,
440
+ lstat_requests , opendir_requests ,
441
+ fscache_requests , fscache_misses );
428
442
fscache_clear ();
429
443
LeaveCriticalSection (& mutex );
430
444
}
@@ -457,6 +471,7 @@ int fscache_lstat(const char *filename, struct stat *st)
457
471
if (!fscache_enabled (filename ))
458
472
return mingw_lstat (filename , st );
459
473
474
+ lstat_requests ++ ;
460
475
/* split filename into path + name */
461
476
len = strlen (filename );
462
477
if (len && is_dir_sep (filename [len - 1 ]))
@@ -538,6 +553,7 @@ DIR *fscache_opendir(const char *dirname)
538
553
if (!fscache_enabled (dirname ))
539
554
return dirent_opendir (dirname );
540
555
556
+ opendir_requests ++ ;
541
557
/* prepare name (strip trailing '/', replace '.') */
542
558
len = strlen (dirname );
543
559
if ((len == 1 && dirname [0 ] == '.' ) ||
0 commit comments